diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 0f4a73768c..219c707ee1 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -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); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php index 54e0dedc4b..b8644ecb9f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php @@ -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' diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php index 09ce8b5683..36823dfc16 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php @@ -1,6 +1,7 @@ __DIR__.'/foo' __DIR__.'/../foo' __DIR__.'/../../../foo/bar.php' +__DIR__ '/some/where/else/foo'