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
This commit is contained in:
commit
511b20d837
@ -479,6 +479,8 @@ class Request
|
||||
*/
|
||||
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();
|
||||
|
@ -1009,6 +1009,15 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user