Skip to content

[2.3][DIC] ContainerBuilder behaviour issue #7636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Apr 12, 2013 · 6 comments
Closed

[2.3][DIC] ContainerBuilder behaviour issue #7636

ghost opened this issue Apr 12, 2013 · 6 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 12, 2013

Since upgrading from Symfony 2.2 to 2.3, I think I might have exposed a change in behaviour that might be a bug.

Background

We made a small change to our kernel to compile the DIC with ContainerBuilder so that we can still add definitions to the DIC after compile. It simply means one cannot overwrite existing services after compile (which I consider a feature). In any case, it worked in 2.2 and there was no reason for it not to.

Since upgrading to 2.3, if I run app/console clear:cache I get a weird exception about the request service. However, if I run app/console cache:clear --no-warmup, then I get no exception. Please see my commit for details of the small change.

$ app/console -v cache:clear
Clearing the cache for the dev environment with debug true

  [Symfony\Component\DependencyInjection\Exception\InactiveScopeException]
    You cannot create a service ("request") of an inactive scope
    ("request").


Exception trace:
 () at app\cache\de_\ap_DevDebugProjectContainer.php:1427
 ap_DevDebugProjectContainer->getRequestService() at app\bootstrap.php.cache:133
 Symfony\Component\DependencyInjection\Container->get() at Symfony\Component\DependencyInjection\ContainerBuilder.php:431
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at app\cache\de_\ap_DevDebugProjectContainer.php:953
 ap_DevDebugProjectContainer->getFragment_HandlerService() at app\bootstrap.php.cache:133
 Symfony\Component\DependencyInjection\Container->get() at Symfony\Component\DependencyInjection\ContainerBuilder.php:431
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at app\cache\de_\ap_DevDebugProjectContainer.php:2666
 ap_DevDebugProjectContainer->getTwigService() at app\bootstrap.php.cache:133
 Symfony\Component\DependencyInjection\Container->get() at Symfony\Component\DependencyInjection\ContainerBuilder.php:431
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at app\cache\de_\ap_DevDebugProjectContainer.php:65
 ap_DevDebugProjectContainer->getAssetic_AssetManagerService() at app\bootstrap.php.cache:133
 Symfony\Component\DependencyInjection\Container->get() at Symfony\Component\DependencyInjection\ContainerBuilder.php:431
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer.php:33
 Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer->warmUp() at Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php:47
 Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:117
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:83
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at Symfony\Component\Console\Command\Command.php:240
 Symfony\Component\Console\Command\Command->run() at Symfony\Component\Console\Application.php:940
 Symfony\Component\Console\Application->doRunCommand() at Symfony\Component\Console\Application.php:204
 Symfony\Component\Console\Application->doRun() at Symfony\Bundle\FrameworkBundle\Console\Application.php:78
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at Symfony\Component\Console\Application.php:117
 Symfony\Component\Console\Application->run() at app\console:22

    cache:clear [--no-warmup] [--no-optional-warmers]

I believe the problem comes in with the new "syncronized" services code that was added.
@beberlei @fabpot

I have no idea why only the cache warmers trigger this error and my application continues to work from the browser.

@ghost
Copy link
Author

ghost commented Apr 15, 2013

Refs #7007 I believe this is related.

@ghost
Copy link
Author

ghost commented Apr 17, 2013

@fabpot - I dont know if this is helpful, but I've found I've found a the point that triggers this error in the fragment handler service definition - if I change the setRequest part to null, the exception is not thrown.

Is there any reason this should trigger the exception when the cache warmers run, but only when the compiled kernel base class is set to ContainerBuilder?

@fabpot
Copy link
Member

fabpot commented Apr 17, 2013

@Drak: thanks for the help. I can now reproduce the issue and I know why it behaves like that. That's a bug and I'm going to provide a fix soon.

@fabpot
Copy link
Member

fabpot commented Apr 17, 2013

@Drak Can you confirm that #7697 fixes your issue?

@fabpot fabpot closed this as completed in edd7649 Apr 18, 2013
fabpot added a commit that referenced this issue Apr 18, 2013
This PR was merged into the master branch.

Discussion
----------

[DependencyInjection] fixed management of scoped services with an invalid behavior set to null

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7636
| License       | MIT
| Doc PR        | n/a

Commits
-------

edd7649 [DependencyInjection] fixed management of scoped services with an invalid behavior set to null (closes #7636)
@ghost
Copy link
Author

ghost commented Apr 18, 2013

Sorry for the late reply. The PR fixes that particular exception. Thanks!

@PaddyLock
Copy link

I'm also experiencing a similar bug with Symfony 2.2.3 (I had to move back to 2.2.2)

php app/console -v cache:clear
Clearing the cache for the dev environment with debug true

[Symfony\Component\DependencyInjection\Exception\InactiveScopeException]
You cannot create a service ("request") of an inactive scope ("request").

Exception trace:
() at /Users/patricklock/Sites/cplus-security/app/cache/de_/ap_DevDebugProjectContainer.php:2051
ap_DevDebugProjectContainer->getRequestService() at /Users/patricklock/Sites/cplus-security/app/bootstrap.php.cache:129
Symfony\Component\DependencyInjection\Container->get() at /Users/patricklock/Sites/cplus-security/app/cache/de_/ap_DevDebugProjectContainer.php:1544
ap_DevDebugProjectContainer->getFragment_HandlerService() at /Users/patricklock/Sites/cplus-security/app/bootstrap.php.cache:129
Symfony\Component\DependencyInjection\Container->get() at /Users/patricklock/Sites/cplus-security/app/cache/de_/ap_DevDebugProjectContainer.php:3324
ap_DevDebugProjectContainer->getTwigService() at /Users/patricklock/Sites/cplus-security/app/bootstrap.php.cache:129
Symfony\Component\DependencyInjection\Container->get() at /Users/patricklock/Sites/cplus-security/app/cache/de_/ap_DevDebugProjectContainer.php:307
ap_DevDebugProjectContainer->getAssetic_AssetManagerService() at /Users/patricklock/Sites/cplus-security/app/bootstrap.php.cache:129
Symfony\Component\DependencyInjection\Container->get() at /Users/patricklock/Sites/cplus-security/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/CacheWarmer/AssetManagerCacheWarmer.php:33
Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer->warmUp() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:47
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:117
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:83
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
Symfony\Component\Console\Command\Command->run() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:899
Symfony\Component\Console\Application->doRunCommand() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:184
Symfony\Component\Console\Application->doRun() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/patricklock/Sites/cplus-security/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /Users/patricklock/Sites/cplus-security/app/console:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants