Skip to content

Commit a20fff9

Browse files
bug #87 Fix populating server params from URI in HttpFoundationFactory (nicolas-grekas)
This PR was merged into the 2.0-dev branch. Discussion ---------- Fix populating server params from URI in HttpFoundationFactory Fix #82 Commits ------- 66095a5 Fix populating server params from URI in HttpFoundationFactory
2 parents 4933e04 + 66095a5 commit a20fff9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Factory/HttpFoundationFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ public function createRequest(ServerRequestInterface $psrRequest, bool $streamed
5353
$server['REQUEST_URI'] = $uri->getPath();
5454
$server['QUERY_STRING'] = $uri->getQuery();
5555

56+
if ('' !== $server['QUERY_STRING']) {
57+
$server['REQUEST_URI'] .= '?'.$server['QUERY_STRING'];
58+
}
59+
5660
if ('https' === $uri->getScheme()) {
5761
$server['HTTPS'] = 'on';
5862
}
5963
}
6064

6165
$server['REQUEST_METHOD'] = $psrRequest->getMethod();
6266

63-
$server = array_replace($server, $psrRequest->getServerParams());
67+
$server = array_replace($psrRequest->getServerParams(), $server);
6468

6569
$parsedBody = $psrRequest->getParsedBody();
6670
$parsedBody = \is_array($parsedBody) ? $parsedBody : [];

Tests/Functional/CovertTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public function requestProvider()
133133
'SERVER_NAME' => 'dunglas.fr',
134134
'SERVER_PORT' => null,
135135
'HTTP_X_SYMFONY' => '2.8',
136-
'REQUEST_URI' => '/testCreateRequest?bar[baz]=42&foo=1',
137-
'QUERY_STRING' => 'foo=1&bar[baz]=42',
136+
'REQUEST_URI' => '/testCreateRequest?foo=1&bar%5Bbaz%5D=42',
137+
'QUERY_STRING' => 'foo=1&bar%5Bbaz%5D=42',
138138
],
139139
'Content'
140140
);

0 commit comments

Comments
 (0)