Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 511b20d

Browse files
bug #11408 [HttpFoundation] Update QUERY_STRING when overrideGlobals (yguedidi)
This PR was merged into the 2.3 branch. Discussion ---------- [HttpFoundation] Update QUERY_STRING when overrideGlobals | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 777666f [HttpFoundation] Update QUERY_STRING when overrideGlobals
2 parents ac6e3a1 + 777666f commit 511b20d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ public function __toString()
479479
*/
480480
public function overrideGlobals()
481481
{
482+
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&')));
483+
482484
$_GET = $this->query->all();
483485
$_POST = $this->request->all();
484486
$_SERVER = $this->server->all();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,15 @@ public function testOverrideGlobals()
10091009

10101010
$this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER);
10111011

1012+
$request->initialize(array('foo' => 'bar', 'baz' => 'foo'));
1013+
$request->query->remove('baz');
1014+
1015+
$request->overrideGlobals();
1016+
1017+
$this->assertEquals(array('foo' => 'bar'), $_GET);
1018+
$this->assertEquals('foo=bar', $_SERVER['QUERY_STRING']);
1019+
$this->assertEquals('foo=bar', $request->server->get('QUERY_STRING'));
1020+
10121021
// restore initial $_SERVER array
10131022
$_SERVER = $server;
10141023
}

0 commit comments

Comments
 (0)