Fix "absolute path" when we look to the cache directory

We should get __DIR__ instead of __DIR__ . '/.'
This commit is contained in:
Benoît Lévêque 2014-05-18 15:17:34 +02:00 committed by Fabien Potencier
parent 309046a207
commit 4735e56c44
3 changed files with 10 additions and 2 deletions

View File

@ -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);
}

View File

@ -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'

View File

@ -1,6 +1,7 @@
__DIR__.'/foo'
__DIR__.'/../foo'
__DIR__.'/../../../foo/bar.php'
__DIR__
'/some/where/else/foo'