-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Service locators can't be decorated #33670
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
[DI] Service locators can't be decorated #33670
Conversation
Would you mind investigating what the fix could be? |
I'm not familiar with DI internals but can give it a shot in upcoming days :) |
3a48003
to
d20d9a7
Compare
@nicolas-grekas bugfix is ready, travis is happy :) |
@nicolas-grekas any chance this could be reviewed and hopefully included in 4.3.6? |
src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php
Outdated
Show resolved
Hide resolved
37e99cc
to
c2400d6
Compare
@nicolas-grekas I've tweaked the order so all existing tests are happy, but I'm not sure what the fail on PHP 7.1 is |
src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
Outdated
Show resolved
Hide resolved
c2400d6
to
1edaed2
Compare
1edaed2
to
343282b
Compare
Thank you @malarzm. |
This PR was squashed before being merged into the 4.3 branch. Discussion ---------- [DI] Service locators can't be decorated | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a This popped up while I was trying to update my work project as we have decorated the `messenger.receiver_locator` service. Not sure if this is a regression in DI or a change in messenger that caused the issue thus I'm not marking this as a BC break. Exception while trying to compile the container: ``` Invalid definition for service "Symfony\Component\DependencyInjection\Tests\Compiler\DecoratedServiceLocator": an array of references is expected as first argument when the "container.service_locator" tag is set. ``` Expected result: service locator can be decorated. Commits ------- 343282b [DI] Service locators can't be decorated
@nicolas-grekas apparently this change was not enough for |
Yes, the command loads a fake container from an XML dump, so this might trigger some differences. Should be checked. |
@nicolas-grekas the problem is caused by a direct call to |
…cator on the decorated definition (malarzm) This PR was merged into the 4.3 branch. Discussion ---------- [DI] DecoratorServicePass should keep container.service_locator on the decorated definition | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #33670 (comment) | License | MIT | Doc PR | - `container.service_locator` is special because it tells how the arguments of the constructor should be interpreted. /cc @malarzm Commits ------- 99dab87 [DI] DecoratorServicePass should keep container.service_locator on the decorated definition
This popped up while I was trying to update my work project as we have decorated the
messenger.receiver_locator
service. Not sure if this is a regression in DI or a change in messenger that caused the issue thus I'm not marking this as a BC break.Exception while trying to compile the container:
Expected result: service locator can be decorated.