Last modified: 2014-11-18 18:07:17 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T66570, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 64570 - mediawiki.api: Serialize { foo: [1,2] } as "foo=1|2" instead of "foo[]=1&foo[]=2"
mediawiki.api: Serialize { foo: [1,2] } as "foo=1|2" instead of "foo[]=1&foo[...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
unspecified
All All
: Low enhancement with 1 vote (vote)
: 1.25.0 release
Assigned To: Marcin Cieślak
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-28 20:34 UTC by Tisza Gergő
Modified: 2014-11-18 18:07 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Tisza Gergő 2014-04-28 20:34:42 UTC
When passing an array to mw.Api as part of the parameters, is it passed unchanged to jQuery.ajax which translates it into the format used when encoding form fields into GET URLs, that is, name[]=value1&name=value2&...

The MediaWiki API does not understands this format; instead, arrays should be joined with a | character.
Comment 1 Bartosz Dziewoński 2014-04-28 20:40:44 UTC
I could have sworn it already does :o. It really doesn't. Huh.
Comment 2 Krinkle 2014-04-28 20:42:39 UTC
Hm.. hinging on invalid/wontfix but will leave open for now.

When an mw.Api plugin provides a dedicated interface for a particular property, it should support a plain array as input and do the join('|') for you.

mediawiki.api.watch is an example where this is handled, and that works fine. There is no problem here.

The generic ajax interface in mw.Api (mw.Api.get) has no contract that it does array joining for you. That could be a feature (reclassified this as an enhancement for that reason), but it certainly isn't something you should expect to work. It is documented as taking query string key/value pairs. If anything, it could reject non-string values before passing to $.param, but that seems a bit of an exaggeration for such a minor detail and not in style with how we generally write our interfaces flexibly.
Comment 3 Carl Fürstenberg 2014-04-28 20:53:55 UTC

*** This bug has been marked as a duplicate of bug 48903 ***
Comment 4 Brad Jorsch 2014-04-28 20:59:31 UTC
This isn't a duplicate of bug 48903. That one is about the API accepting &foo[]=1&foo[]=2 as input, this is about the mw.Api Javascript library not generating that when passed an array from Javascript.
Comment 5 Brad Jorsch 2014-04-28 21:02:23 UTC
(In reply to Brad Jorsch from comment #4)
> This isn't a duplicate of bug 48903. That one is about the API accepting
> &foo[]=1&foo[]=2 as input, this is about the mw.Api Javascript library not
> generating that when passed an array from Javascript.

On further reflection, that bug is titled as "API should accept this" but its comment 0 is more wishy-washy, to the point where it's a duplicate of both this and bug 10262. So let's keep this one open and close the other since this has a clearer focus.
Comment 6 Gerrit Notification Bot 2014-10-06 16:42:19 UTC
Change 164886 had a related patch set uploaded by Krinkle:
mediawiki.api: Transform arrays with join('|') in query parameters

https://gerrit.wikimedia.org/r/164886
Comment 7 Gerrit Notification Bot 2014-10-30 21:09:26 UTC
Change 164886 merged by jenkins-bot:
mediawiki.api: Transform arrays with join('|') in query parameters

https://gerrit.wikimedia.org/r/164886

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links