merged branch fabpot/request-uri-unification (PR #9012)

This PR was merged into the 2.2 branch.

Discussion
----------

[HttpFoundation] tried to keep the original Request URI as much as possible to avoid different behavior between ::createFromGlobals() and ::create()

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8507
| License       | MIT
| Doc PR        | n/a

Commits
-------

4f5b8f0 [HttpFoundation] tried to keep the original Request URI as much as possible to avoid different behavior between ::createFromGlobals() and ::create()
This commit is contained in:
Fabien Potencier 2013-09-12 20:21:33 +02:00
commit 7b93e20e37
2 changed files with 15 additions and 2 deletions

View File

@ -348,11 +348,20 @@ class Request
break;
}
$queryString = '';
if (isset($components['query'])) {
parse_str(html_entity_decode($components['query']), $qs);
$query = array_replace($qs, $query);
if ($query) {
$query = array_replace($qs, $query);
$queryString = http_build_query($query, '', '&');
} else {
$query = $qs;
$queryString = $components['query'];
}
} elseif ($query) {
$queryString = http_build_query($query, '', '&');
}
$queryString = http_build_query($query, '', '&');
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
$server['QUERY_STRING'] = $queryString;

View File

@ -220,6 +220,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('testnopass', $request->getUser());
$this->assertNull($request->getPassword());
$this->assertFalse($request->isSecure());
$request = Request::create('http://test.com/?foo');
$this->assertEquals('/?foo', $request->getRequestUri());
$this->assertEquals(array('foo' => ''), $request->query->all());
}
/**