Skip to content

Commit

Permalink
[HttpFoundation] tried to keep the original Request URI as much as po…
Browse files Browse the repository at this point in the history
…ssible to avoid different behavior between ::createFromGlobals() and ::create()
  • Loading branch information
fabpot committed Sep 12, 2013
1 parent 6ec2cba commit 4f5b8f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -348,11 +348,20 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo
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;
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -220,6 +220,10 @@ public function testCreate()
$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());
}

/**
Expand Down

0 comments on commit 4f5b8f0

Please sign in to comment.