Skip to content

Commit 4ac7aa8

Browse files
committed
minor symfony#24741 [HttpFoundation] refactoring: calculate when need (ReenExe)
This PR was submitted for the 2.7 branch but it was merged into the 3.4 branch instead (closes symfony#24741). Discussion ---------- [HttpFoundation] refactoring: calculate when need | Q | A | ------------- | --- | Branch? | no | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no HttpFoundation Request optimize Commits ------- 79e8f57 [HttpFoundation] refactoring: calculate when need
2 parents e4bbd46 + 79e8f57 commit 4ac7aa8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,12 +1928,12 @@ protected function prepareBaseUrl()
19281928
*/
19291929
protected function prepareBasePath()
19301930
{
1931-
$filename = basename($this->server->get('SCRIPT_FILENAME'));
19321931
$baseUrl = $this->getBaseUrl();
19331932
if (empty($baseUrl)) {
19341933
return '';
19351934
}
19361935

1936+
$filename = basename($this->server->get('SCRIPT_FILENAME'));
19371937
if (basename($baseUrl) === $filename) {
19381938
$basePath = dirname($baseUrl);
19391939
} else {
@@ -1954,8 +1954,6 @@ protected function prepareBasePath()
19541954
*/
19551955
protected function preparePathInfo()
19561956
{
1957-
$baseUrl = $this->getBaseUrl();
1958-
19591957
if (null === ($requestUri = $this->getRequestUri())) {
19601958
return '/';
19611959
}
@@ -1968,12 +1966,14 @@ protected function preparePathInfo()
19681966
$requestUri = '/'.$requestUri;
19691967
}
19701968

1969+
if (null === ($baseUrl = $this->getBaseUrl())) {
1970+
return $requestUri;
1971+
}
1972+
19711973
$pathInfo = substr($requestUri, strlen($baseUrl));
1972-
if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {
1974+
if (false === $pathInfo || '' === $pathInfo) {
19731975
// If substr() returns false then PATH_INFO is set to an empty string
19741976
return '/';
1975-
} elseif (null === $baseUrl) {
1976-
return $requestUri;
19771977
}
19781978

19791979
return (string) $pathInfo;

0 commit comments

Comments
 (0)