Page MenuHomePhabricator

Change array types of queries to conform with normal HTTP GET query string
Closed, InvalidPublic

Description

Instead, of the current syntax, of having array-type attributes defined as key=val1|val2 etc... The normal behavior for a HTTP GET query string is key=val1&key=val2 etc... i.e. they key is duplicated for each value.


Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=64570

Details

Reference
bz10262

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:51 PM
bzimport set Reference to bz10262.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

What standard specifies this as the normal behavior?

Just noticed, that for php to accept multiple same names, they must be followed by a [], as in:
<form method="get">
<input type="checkbox" value="a" name="foo[]" /><label for="foo">Foo</label><br/>
<input type="checkbox" value="b" name="foo[]" /><label for="bar">Bar</label><br/>
<input type="checkbox" value="c" name="foo[]" /><label for="baz">Baz</label><br/>
<input type="submit"/>
</form>

which will generate:
test.php?foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c

and an array:
Array
(

[foo] => Array
    (
        [0] => a
        [1] => b
        [2] => c
    )

)

from $_GET

perhaps this would be too cumbersome for the api.

Consider what this would mean when requesting a hundred titles:

api.php?action=query&prop=info&titles[]=a&titles[]=b&titles[]=c&...

versus:

api.php?action=query&prop=info&titles=a|b|c|...

The query string using the titles[] approach grows very long very quickly. Besides, converting an array to the a|b|c format is very easy with PHP's implode function.

(In reply to comment #3)

Consider what this would mean when requesting a hundred titles:

api.php?action=query&prop=info&titles[]=a&titles[]=b&titles[]=c&...

versus:

api.php?action=query&prop=info&titles=a|b|c|...

The query string using the titles[] approach grows very long very quickly.
Besides, converting an array to the a|b|c format is very easy with PHP's
implode function.

In that you are right. :)

  • Bug 48903 has been marked as a duplicate of this bug. ***
  • Bug 48903 has been marked as a duplicate of this bug. ***