Skip to content

Commit

Permalink
[HttpFoundation] Behaviour change in PHP7 for substr
Browse files Browse the repository at this point in the history
In PHP7 the behaviour of substr() changed.
To resume: "Truncating an entire string should result in a string."

See: https://bugs.php.net/bug.php?id=62922
  • Loading branch information
Tristan Darricau committed Jul 15, 2015
1 parent 9962f36 commit ba6000b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -1790,7 +1790,8 @@ protected function preparePathInfo()
$requestUri = substr($requestUri, 0, $pos);
}

if (null !== $baseUrl && false === $pathInfo = substr($requestUri, strlen($baseUrl))) {
$pathInfo = substr($requestUri, strlen($baseUrl));
if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {
// If substr() returns false then PATH_INFO is set to an empty string

This comment has been minimized.

Copy link
@GromNaN

GromNaN Jul 19, 2015

Member

Is this comment still correct ?
As I can see, substr() can return an empty string or false; and in that case the PATH_INFO is set to '/' instead of an empty string.

return '/';
} elseif (null === $baseUrl) {
Expand Down

0 comments on commit ba6000b

Please sign in to comment.