Last modified: 2012-07-19 21:15:51 UTC
mw.Uri.js models the query as an object of simple key-values. This is not strictly correct as you can have key=value&key=anotherValue If it is to replace certain functions in mw.util.js, such as getParamValue it needs to handle that case.
More precise, it needs to return the last one (since that one overwrites the earlier one). Most regexes around (haven't looked into mw.Uri.js), stop at the first match.
Krinkle: no, that's not correct -- in the HTTP standard it is permissible to have multiple values for a key in the query string, and they all count. In HTML, this can result from submitting a form with a SELECT with the MULTIPLE attribute on, so you can select multiple values. Or are you saying that something in MediaWiki parses URLs that way? If so it's wrong.
Unassigning default assignments. http://article.gmane.org/gmane.science.linguistics.wikipedia.technical/54734
It is permissible to have an argument appear multiple times, however *unless its name ends in "[]" PHP will just overwrite all the earlier ones with the later ones when it interprets input. Query string / POST elements whose names end in '[]' or '[<index>]' produce array elements, which may have either numeric or string keys. If you have [] on the end of the name, then it saves the one-or-more elements into an array with the name without the []. Within MediaWiki we fairly consistently use the associative-array model here, with sub-arrays for multiple items getting the [] added on the generated URL: > parse_str('a[]=b&a[]=c', $foo); var_export($foo); array ( 'a' => array ( 0 => 'b', 1 => 'c', ), ) > parse_str('a[xx]=b&a[yy]=c', $foo); var_export($foo); array ( 'a' => array ( 'xx' => 'b', 'yy' => 'c', ), ) > return wfArrayToCGI(array('a' => array('b', 'c'))); a%5B0%5D=b&a%5B1%5D=c > return wfArrayToCGI(array('a' => array('xx' => 'b', 'yy' => 'c'))); a%5Bxx%5D=b&a%5Byy%5D=c mw.Uri should probably model these similarly... $.param already seems to do this for serializing parameters into query strings: >>> $.param({a: "b"}); "a=b" >>> $.param({a: ["b", "c"]}); "a%5B%5D=b&a%5B%5D=c" >>> $.param({a: {xx: "b", yy: "c"}}); "a%5Bxx%5D=b&a%5Byy%5D=c"
Moving bug out of UploadWizard to core, as this JS module has migrated into core.
This bug is resolved, just was lazy about marking it. The migration to core has obscured history a bit but see lines 169-176, or look at r83691. As for compatibility with what PHP wants to see that seems to be a matter of the application doing the right thing when constructing the URI. It is not a given that all URIs constructed with this module are supposed to be consumed by MediaWiki or PHP.
Okay, actually, maybe it would be a good idea to handle all that with $.param(), and there is a decently documented function in jQuery BBQ which unserializes URLs much like $.param(), even for complex values like ?foo[a][b]=var . However, now I remember why I didn't use $.param(); we like to escape things differently (for whatever reason we always escape parentheses, for example). Looking into whether I can fiddle with jQuery's escaping routines there.
This appears to be very resolved. mw.Uri now handles multiple arguments as an array, properly. Also, while I cannot find the relevant code, there is a commit message that says something about more-PHP-like array handling.