-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Running container is being deleted when dependency is autowired implicitly in Symfony 3 #27053
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
Comments
Could you provide a repo with a reproducer? |
This one is very close. Run phpunit |
I think the |
…loaded (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Don't clean legacy containers that are still loaded | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27053 | License | MIT | Doc PR | - Commits ------- be8dbc3 [HttpKernel] Don't clean legacy containers that are still loaded
This fixed the fatal error, great job 👍 However, it doesn't fix the issue of container being unnecessarily re-generated after each request. Should I create separate issue for that? |
Can you debug it a bit? Is this something Symfony can do about, or the bundle should do? Depending on the answer you can open an issue yes. |
Will try, but I doubt I can debug it in reasonable time. Internals are pretty unreadable to me. Lot of nesting, inlining and no comments. I would need some help with debugging that. Is there some material explaining internals of DI? |
The container being regenerated all the time is related to JMSDIExtraBundle replacing the EntityManager service with its own service, but defining the service class only later. As the autowiring considers non-existent classes differently than existing classes regarding freshness (as it has to inspect types for services), this causes issues. |
I have changed constructor dependency from Doctrine's ApplicationRepository (which has service ID same as FCQN) into dependency which has ID not matching FCQN, configured with legacy style, like:
It works. BUT
After doing that, tests started to blow up with messages like:
Test looks like this:
What I found is that after each $client->request(), container is being replaced, so when it comes to executing
$oppManager->findOneBy()
, old container folder does no longer exist, so classes which weren't loaded yet at that point, cannot.I also tried to find out why is container being regenerated and what I found is that resource is marked as ClassExistenceResource for
EntityManager5ae0c6b8bc55b_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager
. Such key hasfalse
value in\Symfony\Component\Config\Resource\ClassExistenceResource#existsCache[1]
. Variable $exists is true and $this->exists is false. This results in false return.This issue has been discovered in Symfony 3.4.4. I updated and is still present in Symfony 3.4.8.
Issue is resolved when I alias the service so FCQN matches ID:
Here are some other things which might help:
I realize these autowiring fallbacks are deprecated, but it shouldn't blow up like this and will make it hard to migrate
The text was updated successfully, but these errors were encountered: