Skip to content

[HttpKernel] Illegal paths in generated container #10976

@covex-nn

Description

@covex-nn

I've tried to optimize performance of vagrant dev-environment running with Symfony 2.3.

So, i moved vendor-dir inside virtual machine from shared folder /vagrant/vendor into /home/vagrant/share/vendor and created symlink from /home/vagrant/share/vendor to /vagrant/vendor

And now on the main page http://www.local/app_dev.php/ there is an error:

Twig_Error_Loader: The "/home/vagrant/app/cache/dev/../../../share/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/views" directory does not exist.

(app_dev.php is inside /vagrant/web dir and app/cache is /vagrant/app/cache)

Inside /vagrant/app/cache/dev/appDevDebugProjectContainer.php file i have this function for twig.loader service:

    protected function getTwig_LoaderService()
    {
        $this->services['twig.loader'] = $instance = new \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader($this->get('templating.locator'), $this->get('templating.name_parser'));

        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/views', 'Framework');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/views', 'Security');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views', 'Twig');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/views', 'Swiftmailer');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Resources/views', 'Doctrine');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/apnet/layout-bundle/src/Apnet/LayoutBundle/Resources/views', 'ApnetLayout');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/Resources/views', 'WebProfiler');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/views', 'SensioDistribution');
        $instance->addPath(__DIR__.'/../../Resources/views');
        $instance->addPath('/home'.__DIR__.'/../../../share/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form');

        return $instance;
    }

So, i think that i've found a bug in Symfony\Component\HttpKernel\Kernel::removeAbsolutePathsFromContainer, it came from issue #10894

I think, that there is something wrong with regular expression "{'([^']*)(".preg_quote($rootDir)."[^']*)'}", but i do not know how to fix it =(

But i've changes fixtures for testRemoveAbsolutePathsFromContainer in Symfony\Component\HttpKernel\Tests\KernelTest in https://github.com/covex-nn/symfony/commit/ea654f18fa3ef160e56e95bf88edab3ad78aff80

Here is phpunit output

vagrant@www:/vagrant/symfony$ phpunit src/Symfony/Component/HttpKernel/Tests/KernelTest.php
PHPUnit 4.1.0 by Sebastian Bergmann.

Configuration read from /vagrant/symfony/phpunit.xml.dist

...........................................F.

Time: 602 ms, Memory: 20.50Mb

There was 1 failure:

1) Symfony\Component\HttpKernel\Tests\KernelTest::testRemoveAbsolutePathsFromContainer
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '/some/where/else/foo'
-'/some/ROOT_DIR/ROOT_DIR/foo'
+'/some//vagrant/symfony/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/'.__DIR__.'/../../../foo'

 'file:'.__DIR__.'/profiler'
 '

/vagrant/symfony/src/Symfony/Component/HttpKernel/Tests/KernelTest.php:838

FAILURES!                              
Tests: 45, Assertions: 93, Failures: 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions