Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolas-grekas committed Aug 13, 2014
2 parents ac6e3a1 + 777666f commit 511b20d
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 511b20d

Please sign in to comment.