Merge "Fix PHP warning with some inputs to wfCgiToArray()"

This commit is contained in:
jenkins-bot 2021-10-25 18:58:01 +00:00 committed by Gerrit Code Review
commit 98fbea6293
2 changed files with 5 additions and 2 deletions

View file

@ -399,7 +399,7 @@ function wfCgiToArray( $query ) {
$k = substr( $k, 0, -1 );
$temp = [ $k => $temp ];
}
if ( isset( $ret[$key] ) ) {
if ( isset( $ret[$key] ) && is_array( $ret[$key] ) ) {
$ret[$key] = array_merge( $ret[$key], $temp );
} else {
$ret[$key] = $temp;

View file

@ -192,7 +192,8 @@ class GlobalTest extends MediaWikiIntegrationTestCase {
[ 'foo', [ 'foo' => '' ] ], // missing =
[ 'foo=bar&qwerty=asdf', [ 'foo' => 'bar', 'qwerty' => 'asdf' ] ], // multiple value
[ 'foo=A%26B%3D5%2B6%40%21%22%27', [ 'foo' => 'A&B=5+6@!"\'' ] ], // urldecoding test
[ 'foo%5Bbar%5D=baz', [ 'foo' => [ 'bar' => 'baz' ] ] ],
[ 'foo[bar]=baz', [ 'foo' => [ 'bar' => 'baz' ] ] ],
[ 'foo%5Bbar%5D=baz', [ 'foo' => [ 'bar' => 'baz' ] ] ], // urldecoding test 2
[
'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf',
[ 'foo' => [ 'bar' => 'baz', 'qwerty' => 'asdf' ] ]
@ -202,6 +203,8 @@ class GlobalTest extends MediaWikiIntegrationTestCase {
'foo%5Bbar%5D%5Bbar%5D=baz',
[ 'foo' => [ 'bar' => [ 'bar' => 'baz' ] ] ]
],
[ 'foo[]=x&foo[]=y', [ 'foo' => [ '' => 'y' ] ] ], // implicit keys are NOT handled like in PHP (bug?)
[ 'foo=x&foo[]=y', [ 'foo' => [ '' => 'y' ] ] ], // mixed value/array doesn't cause errors
];
}