-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[DependencyInjection] Services no longer injected into __invoke controllers method #27208
Comments
Would you mind creating a small example application that allows to reproduce? |
I can't reproduce it yet so my explanation must be wrong. Still investigating. |
is your service tagged with |
@stof not my service but the controller. I started from the default SendinBlue\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments'] |
The issue really comes from |
Should be fixed by #27214 |
…voke controllers method (ogizanagi) This PR was merged into the 4.1 branch. Discussion ---------- [HttpKernel] Fix services are no longer injected into __invoke controllers method | Q | A | ------------- | --- | Branch? | 4.1 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27208 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A _TL;DR:_ The `RemoveEmptyControllerArgumentLocatorsPass` is the one adding the `Controller::_invoke` => `Controller` shortcut missing from the service locator. It isn't properly executed on some cases. This fixes it. Since #26833, the resolvers are decorated by a `TraceableValueResolver`, which usually isn't much an issue to deal within passes. But the `RemoveEmptyControllerArgumentLocatorsPass` happens late (`TYPE_BEFORE_REMOVING`), when decoration inheritance is already resolved, so accessing `$controllerLocator = $container->getDefinition((string) $serviceResolver->getArgument(0));` isn't accessing the controller locator, but the decorated service instead. Commits ------- ee44903 [HttpKernel] Fix services are no longer injected into __invoke controllers method
Symfony version(s) affected: 4.1.0-BETA1
Description
After upgrading to 4.0.8 to 4.1.0-BETA1 some controllers stopped working, displaying
After some debugging it appears
ServiceValueResolver
's container doesn't contain the controller so itssupports
method returnsfalse
.How to reproduce
Typehint a controller's
__invoke
method argument with a service class and then navigate to a route calling this method.The text was updated successfully, but these errors were encountered: