bug #10937 [HttpKernel] Fix "absolute path" when we look to the cache directory (BenoitLeveque)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #10937).
Discussion
----------
[HttpKernel] Fix "absolute path" when we look to the cache directory
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
We should get ``__DIR__`` instead of ``__DIR__ . '/.'``
I've seen this issue when trying to play with the symfony standard new directory structure
Commits
-------
4735e56
Fix "absolute path" when we look to the cache directory
This commit is contained in:
commit
7dc8931969
|
@ -748,9 +748,15 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
|||
$filesystem = new Filesystem();
|
||||
|
||||
return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) {
|
||||
$prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__.'/" : "__DIR__.'/";
|
||||
$prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__" : "__DIR__";
|
||||
|
||||
return $prefix.rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/')."'";
|
||||
$relativePath = rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/');
|
||||
|
||||
if ($relativePath === '.') {
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
return $prefix . ".'/" . $relativePath . "'";
|
||||
}, $content);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'ROOT_DIR/app/cache/dev/foo'
|
||||
'ROOT_DIR/app/cache/foo'
|
||||
'ROOT_DIR/foo/bar.php'
|
||||
'ROOT_DIR/app/cache/dev'
|
||||
|
||||
'/some/where/else/foo'
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
__DIR__.'/foo'
|
||||
__DIR__.'/../foo'
|
||||
__DIR__.'/../../../foo/bar.php'
|
||||
__DIR__
|
||||
|
||||
'/some/where/else/foo'
|
||||
|
||||
|
|
Reference in New Issue