Skip to content

Commit e8b31ea

Browse files
committed
Revert "bug #10894 [HttpKernel] removed absolute paths from the generated container (fabpot)"
This reverts commit 735e9a4, reversing changes made to 5c91dc1.
1 parent 86ea15f commit e8b31ea

File tree

7 files changed

+1
-86
lines changed

7 files changed

+1
-86
lines changed

Kernel.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use Symfony\Component\Config\Loader\DelegatingLoader;
3333
use Symfony\Component\Config\ConfigCache;
3434
use Symfony\Component\ClassLoader\ClassCollectionLoader;
35-
use Symfony\Component\Filesystem\Filesystem;
3635

3736
/**
3837
* The Kernel is the heart of the Symfony system.
@@ -717,43 +716,9 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
717716
$content = static::stripComments($content);
718717
}
719718

720-
$content = $this->removeAbsolutePathsFromContainer($content);
721-
722719
$cache->write($content, $container->getResources());
723720
}
724721

725-
/**
726-
* Converts absolute paths to relative ones in the dumped container.
727-
*/
728-
private function removeAbsolutePathsFromContainer($content)
729-
{
730-
if (!class_exists('Symfony\Component\Filesystem\Filesystem')) {
731-
return $content;
732-
}
733-
734-
// find the "real" root dir (by finding the composer.json file)
735-
$rootDir = $this->getRootDir();
736-
$previous = $rootDir;
737-
while (!file_exists($rootDir.'/composer.json')) {
738-
if ($previous === $rootDir = realpath($rootDir.'/..')) {
739-
// unable to detect the project root, give up
740-
return $content;
741-
}
742-
743-
$previous = $rootDir;
744-
}
745-
746-
$rootDir = rtrim($rootDir, '/');
747-
$cacheDir = $this->getCacheDir();
748-
$filesystem = new Filesystem();
749-
750-
return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) {
751-
$prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__.'/" : "__DIR__.'/";
752-
753-
return $prefix.rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/')."'";
754-
}, $content);
755-
}
756-
757722
/**
758723
* Returns a loader for the container.
759724
*

Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

Tests/Fixtures/DumpedContainers/composer.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

Tests/Fixtures/KernelForTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
class KernelForTest extends Kernel
1818
{
19-
public function setRootDir($dir)
20-
{
21-
$this->rootDir = $dir;
22-
}
23-
2419
public function getBundleMap()
2520
{
2621
return $this->bundleMap;

Tests/KernelTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -824,34 +824,6 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
824824
$kernel->terminate(Request::create('/'), new Response());
825825
}
826826

827-
public function testRemoveAbsolutePathsFromContainer()
828-
{
829-
$kernel = new KernelForTest('dev', true);
830-
$kernel->setRootDir($symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app');
831-
832-
$content = file_get_contents($symfonyRootDir.'/cache/dev/withAbsolutePaths.php');
833-
$content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content);
834-
835-
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
836-
$m->setAccessible(true);
837-
$content = $m->invoke($kernel, $content);
838-
$this->assertEquals(file_get_contents($symfonyRootDir.'/cache/dev/withoutAbsolutePaths.php'), $content);
839-
}
840-
841-
public function testRemoveAbsolutePathsFromContainerGiveUpWhenComposerJsonPathNotGuessable()
842-
{
843-
$kernel = new KernelForTest('dev', true);
844-
$kernel->setRootDir($symfonyRootDir = sys_get_temp_dir());
845-
846-
$content = file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php');
847-
$content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content);
848-
849-
$m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer');
850-
$m->setAccessible(true);
851-
$newContent = $m->invoke($kernel, $content);
852-
$this->assertEquals($newContent, $content);
853-
}
854-
855827
protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null)
856828
{
857829
$bundle = $this

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"symfony/console": "~2.2",
3030
"symfony/dependency-injection": "~2.0",
3131
"symfony/finder": "~2.0",
32-
"symfony/filesystem": "~2.4",
3332
"symfony/process": "~2.0",
3433
"symfony/routing": "~2.2",
3534
"symfony/stopwatch": "~2.2",
@@ -41,8 +40,7 @@
4140
"symfony/config": "",
4241
"symfony/console": "",
4342
"symfony/dependency-injection": "",
44-
"symfony/finder": "",
45-
"symfony/filesystem": ""
43+
"symfony/finder": ""
4644
},
4745
"autoload": {
4846
"psr-0": { "Symfony\\Component\\HttpKernel\\": "" }

0 commit comments

Comments
 (0)