-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Cache] Do not process cache aliases that are not present in the container #29384
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
Conversation
I don't think that works: the container in |
@nicolas-grekas You defined default value for pdo here ->scalarNode('default_pdo_provider')->defaultValue('doctrine.dbal.default_connection')->end() and used existing loop that calls |
That default config leads to the creation an alias named Please provide a reproducer if you still think there is a bug - or at least more details. |
@nicolas-grekas I probably can provide a minimal installation on Monday, but I think I'm either missing a point or can't explain myself well. |
Everything works when playing with eg the website-skeleton - even without Doctrine. So yes, I don't see the issue right now. Looking forward to your reproducer :) |
Ok, i think I found the problem. <service id="cache.default_pdo_provider" alias="doctrine.dbal.default_connection" public="false"/> This will obviously crash if To be clear: I believe that the suggested fix shouldn't be taken as is since I do not know what the initial intention of the feature was, but creating alias to a non-existent service shouldn't be done either. |
Do you experience the issue or not? If this is purely theoretical, then you should know there are tons of services that rely on this behavior. Or if it's something that can be reproduced, please, really, describe how you get it. |
OH OK! Then that's the issue. There can be way more things that could break with this strategy. services:
test.my_service:
alias: my_service
public: true |
@nicolas-grekas This works if you need to mock couple of them. If you have dozens this is not that good of approach.
but this behavior causes a lot of side effects as well (#29359). |
While merging unrelated PRs, one of them made me remind we have a way to deal with such situations. |
@nicolas-grekas Hey, thanks for the update. I do have a workaround by just setting up default_pdo_driver to null in the config though. |
Thanks for reporting and for the discussion. |
…only if the package is installed (nicolas-grekas) This PR was merged into the 4.2 branch. Discussion ---------- [FrameworkBundle] define doctrine as default_pdo_provider only if the package is installed | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29384 | License | MIT | Doc PR | - Commits ------- cf75012 [FrameworkBundle] define doctrine as default_pdo_provider only if the package is installed
1484117
Introduced a major problem when framework-bundle is used WITHOUT doctrine.
On kernel compilation this results in ServiceNotFoundException: You have requested a non-existent service "doctrine.dbal.default_connection".
This is due to the fact there is no check whether such definition is present in the container
Since there is no clear view as how to handle such a situation (remove default value from configuration or ignore those that are not present) I chose the latter.