Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Optimized autowiring breaks existing installations #48138

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

Closed
brusch opened this issue Nov 7, 2022 · 11 comments · Fixed by #48172
Closed

[DependencyInjection] Optimized autowiring breaks existing installations #48138

brusch opened this issue Nov 7, 2022 · 11 comments · Fixed by #48172

Comments

@brusch
Copy link
Contributor

brusch commented Nov 7, 2022

Symfony version(s) affected

6.2-dev

Description

Regression caused by #46279

Registering Response as an abstract service here, causes the following error message:

The definition ".service_locator.Fz2ZPLc" has a reference to an abstract definition "Symfony\Component\HttpFoundation\Response". Abstract definitions cannot be the target of references.

How to reproduce

Just use an existing Symfony project with 6.2-dev and build the container.
See also https://github.com/pimcore/pimcore/actions/runs/3408995937/jobs/5670226500#step:7:702

Possible Solution

Removing the following line fixes the issue for me:

->set(Response::class)->abstract()->tag('container.excluded')

Additional Context

No response

@MatTheCat
Copy link
Contributor

MatTheCat commented Nov 8, 2022

Just use an existing Symfony project with 6.2-dev and build the container.

Nope. This happens when a controller method has a nullable Response argument (like Pimcore\Controller\FrontendController::renderTemplate).

@brusch
Copy link
Contributor Author

brusch commented Nov 8, 2022

@MatTheCat Thanks for the info, but still, it works with 6.1 and breaks with 6.2, right?

@nicolas-grekas
Copy link
Member

Would you be able to submit a failing test case maybe? There must be a compiler pass to fix that should skip registering, likely RegisterControllerArgumentLocatorsPass.

@MatTheCat
Copy link
Contributor

MatTheCat commented Nov 8, 2022

@brusch yep.

@brusch
Copy link
Contributor Author

brusch commented Nov 8, 2022

Unfortunately I'm not into all details of that topic, but I'll have a look 😉

@MatTheCat
Copy link
Contributor

I guess

if (Request::class === $type || SessionInterface::class === $type) {
continue;
}
should also check for Response 🤔

@nicolas-grekas
Copy link
Member

@MatTheCat absolutely, that'd do it!

@MatTheCat
Copy link
Contributor

MatTheCat commented Nov 8, 2022

Are you up for a pull request @brusch? I think you can use RegisterControllerArgumentLocatorsPassTest::testEnumArgumentIsIgnored as a model for the new test case (since we want to ignore Response).

@brusch
Copy link
Contributor Author

brusch commented Nov 9, 2022

@MatTheCat unfortunately not within a reasonable time I guess, maybe next week 😳

@MatTheCat
Copy link
Contributor

No problem: I opened #48172 for you!

nicolas-grekas added a commit that referenced this issue Nov 9, 2022
…roller.service_arguments (MatTheCat)

This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead.

Discussion
----------

[HttpKernel] Don’t try to wire Response argument with controller.service_arguments

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #48138
| License       | MIT
| Doc PR        | N/A

Commits
-------

7832d8d [HttpKernel] Don’t try to wire Response argument with controller.service_arguments
@brusch
Copy link
Contributor Author

brusch commented Nov 10, 2022

@MatTheCat Thank you very much! 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants