-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.3] Return BC compatibility for DI Container #8392
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
When setting service to `null` it's considered as existing instead of removed/reset state. This PR returns BC compatibility and provides test to ensure that BC is hold.
+1 |
@fabpot could this be merged ? The regression in 2.3 for resetManager is quite annoying. |
+1 |
I have tested this PR as is and it still doesn't fix the problem being addressed. // re-use shared service instance if it exists
if (array_key_exists($id, $this->services)) {
return $this->services[$id];
} which makes the service container return null values. However, changing that to isset() raises another issues, I started to get the following error: |
+1, this unfortunately limits us upgrading from 2.2.x to 2.3.x |
+1 |
2 similar comments
+1 |
+1 |
This fix will not work completely.
You missed this part in your pull request. This array_key_exists has to be changed to isset() as well. |
This PR cannot be merged as the change from |
@fabpot The change from isset to array_key_exists is also what broke the registry in 2.3 (and it was not covered by tests). If setting the service to |
random brain spin May I suggest placeholders to indicate what is supposed to happen with the service key?
This could tell the get() to return it but re-initialize the initial service before the actual return happens. |
@fabpot what was the reason for that particular change? Or do you have a reference as to where this was discussed? Only thing I can seem to find is the commit (ec1e7ca), but that description does not make things much clearer to me. Anyway, as it seems to me it does not make sense to have entries in the |
@jankramer |
Can you test PR #8582 which should fix the issue and keep BC? |
Symfony tests pass and my local tests tell me that it fixes the issue with Doctrine as well. So, just waiting for some more confirmation from more real-world projects before merging the fix. |
Yep, just tested and this fixes some issues for me as well. |
I've just upgraded one of my projects that had this issue and my patch does fix the problem. |
Closing in favor of #8582 |
This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] fixed regression where setting a service to null did not trigger a re-creation of the service when getting it (closes #8392) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8392 | License | MIT | Doc PR | n/a Commits ------- 50d0727 [DependencyInjection] fixed regression where setting a service to null did not trigger a re-creation of the service when getting it
When setting service to
null
it's considered as existing instead of removed/reset state which is BC break, more in #8347.