Skip to content

Commit

Permalink
[HttpFoundation] Update QUERY_STRING when overrideGlobals
Browse files Browse the repository at this point in the history
  • Loading branch information
yguedidi committed Jul 30, 2014
1 parent 71edf38 commit 777666f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -479,6 +479,8 @@ public function __toString()
*/
public function overrideGlobals()
{
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&')));

$_GET = $this->query->all();
$_POST = $this->request->all();
$_SERVER = $this->server->all();
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -1009,6 +1009,15 @@ public function testOverrideGlobals()

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

$request->initialize(array('foo' => 'bar', 'baz' => 'foo'));
$request->query->remove('baz');

$request->overrideGlobals();

$this->assertEquals(array('foo' => 'bar'), $_GET);
$this->assertEquals('foo=bar', $_SERVER['QUERY_STRING']);
$this->assertEquals('foo=bar', $request->server->get('QUERY_STRING'));

// restore initial $_SERVER array
$_SERVER = $server;
}
Expand Down

0 comments on commit 777666f

Please sign in to comment.