Skip to content

Commit 06bb7e3

Browse files
committed
[HttpFoundation] use InputBag for POST requests too
1 parent 79f6a5c commit 06bb7e3

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Request
9191
/**
9292
* Request body parameters ($_POST).
9393
*
94-
* @var InputBag|ParameterBag
94+
* @var InputBag
9595
*/
9696
public $request;
9797

@@ -275,7 +275,7 @@ public function __construct(array $query = [], array $request = [], array $attri
275275
*/
276276
public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
277277
{
278-
$this->request = new ParameterBag($request);
278+
$this->request = new InputBag($request);
279279
$this->query = new InputBag($query);
280280
$this->attributes = new ParameterBag($attributes);
281281
$this->cookies = new InputBag($cookies);
@@ -305,9 +305,7 @@ public static function createFromGlobals()
305305
{
306306
$request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
307307

308-
if ($_POST) {
309-
$request->request = new InputBag($_POST);
310-
} elseif (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
308+
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
311309
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
312310
) {
313311
parse_str($request->getContent(), $data);
@@ -457,7 +455,7 @@ public function duplicate(array $query = null, array $request = null, array $att
457455
$dup->query = new InputBag($query);
458456
}
459457
if (null !== $request) {
460-
$dup->request = new ParameterBag($request);
458+
$dup->request = new InputBag($request);
461459
}
462460
if (null !== $attributes) {
463461
$dup->attributes = new ParameterBag($attributes);

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,11 +1287,6 @@ public function testCreateFromGlobals($method)
12871287
{
12881288
$normalizedMethod = strtoupper($method);
12891289

1290-
$_POST = [];
1291-
$request = Request::createFromGlobals();
1292-
$this->assertNotInstanceOf(InputBag::class, $request->request);
1293-
$this->assertInstanceOf(ParameterBag::class, $request->request);
1294-
12951290
$_GET['foo1'] = 'bar1';
12961291
$_POST['foo2'] = 'bar2';
12971292
$_COOKIE['foo3'] = 'bar3';

0 commit comments

Comments
 (0)