File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1211,7 +1211,7 @@ public function getParams(array $only = null)
1211
1211
$ params = $ this ->getQueryParams ();
1212
1212
$ postParams = $ this ->getParsedBody ();
1213
1213
if ($ postParams ) {
1214
- $ params = array_merge ($ params , (array )$ postParams );
1214
+ $ params = array_replace ($ params , (array )$ postParams );
1215
1215
}
1216
1216
1217
1217
if ($ only ) {
Original file line number Diff line number Diff line change @@ -213,6 +213,26 @@ public function testCreateFromEnvironmentWithMultipart()
213
213
$ this ->assertEquals (['foo ' => 'bar ' ], $ request ->getParsedBody ());
214
214
}
215
215
216
+ public function testCreateFromEnvironmentWithMultipartAndQueryParams ()
217
+ {
218
+ $ _POST ['123 ' ] = 'bar ' ;
219
+
220
+ $ env = Environment::mock ([
221
+ 'SCRIPT_NAME ' => '/index.php ' ,
222
+ 'REQUEST_URI ' => '/foo ' ,
223
+ 'REQUEST_METHOD ' => 'POST ' ,
224
+ 'QUERY_STRING ' => '123=zar ' ,
225
+ 'HTTP_CONTENT_TYPE ' => 'multipart/form-data; boundary=---foo '
226
+ ]);
227
+
228
+ $ request = Request::createFromEnvironment ($ env );
229
+ unset($ _POST );
230
+
231
+ # Fixes the bug that would make it previously return [ 0 => 'bar' ]
232
+ $ this ->assertEquals (['123 ' => 'bar ' ], $ request ->getParams ());
233
+ $ this ->assertEquals (['123 ' => 'zar ' ], $ request ->getQueryParams ());
234
+ }
235
+
216
236
/**
217
237
* @covers Slim\Http\Request::createFromEnvironment
218
238
*/
You can’t perform that action at this time.
0 commit comments