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:
commit
7b93e20e37
@ -348,11 +348,20 @@ class Request
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$queryString = '';
|
||||||
if (isset($components['query'])) {
|
if (isset($components['query'])) {
|
||||||
parse_str(html_entity_decode($components['query']), $qs);
|
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['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
|
||||||
$server['QUERY_STRING'] = $queryString;
|
$server['QUERY_STRING'] = $queryString;
|
||||||
|
@ -220,6 +220,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('testnopass', $request->getUser());
|
$this->assertEquals('testnopass', $request->getUser());
|
||||||
$this->assertNull($request->getPassword());
|
$this->assertNull($request->getPassword());
|
||||||
$this->assertFalse($request->isSecure());
|
$this->assertFalse($request->isSecure());
|
||||||
|
|
||||||
|
$request = Request::create('http://test.com/?foo');
|
||||||
|
$this->assertEquals('/?foo', $request->getRequestUri());
|
||||||
|
$this->assertEquals(array('foo' => ''), $request->query->all());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user