-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Deprecate ContainerInterface aliases #35879
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] Deprecate ContainerInterface aliases #35879
Conversation
Will there be a replacement option? |
Yes, you would have to define those aliases in your project. |
I'm not sure what you mean here: AbstractController is a service subscriber, it doesn't use the main container. Looks good to me otherwise (I didn't review the details yet.) |
So, please show me a small example because I'm not sure of these changes ... and if it works, why remove it? |
Indeed, that's a bad example 😅 What I mean is that our own code (untested code since all tests passes) might rely on those aliases and we will need to fix that.
For example, in YAML: Psr\Container\ContainerInterface:
alias: "service_container" Check https://symfony.com/doc/current/service_container/alias_private.html#aliasing.
For the reasons I described in the PR description. |
That shouldn't be the case - we don't use autowiring in core. Did you find any? |
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
Outdated
Show resolved
Hide resolved
8225445
to
76172b8
Compare
@@ -148,6 +152,9 @@ private function createContainer($sessionStorageOptions) | ||
$pass = new AddSessionDomainConstraintPass(); | ||
$pass->process($container); | ||
|
||
$container->setDefinition('.service_subscriber.fallback_container', new Definition(Container::class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test class does not compile the container so the RegisterServiceSubscribersPass
pass is not executed. Consequently, services that have Psr\Container\ContainerInterface
as an argument that would normally be replaced by a smaller locator tag end up relying on the autowired global container, and on the deprecated alias, so they trigger a deprecation.
76172b8
to
42fe4fc
Compare
Rebase needed. |
TODO: waiting for #36295 because tests can't pass atm. |
42fe4fc
to
6162ca8
Compare
Thank you @fancyweb. |
Account for the symfony deprecation in symfony/symfony#35879 which deprecated the default alias for Psr\Container\ContainerInterface and flooded our deprecaton logs since #94269. This deprecation is intended to help with symfony service locators (which we do not use), but would break our usecases once we update to symfony v6 as TYPO3 core and extensions rely on service_container autowiring for the PSR ContainerInterface alias. Releases: master Resolves: #94453 Related: #94269 Change-Id: I0599b3a8a5640faf2fac5094175ae2a6fb37a0a3 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69678 Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Benjamin Franzke <bfr@qbus.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Benjamin Franzke <bfr@qbus.de>
Account for the symfony deprecation in symfony/symfony#35879 which deprecated the default alias for Psr\Container\ContainerInterface and flooded our deprecaton logs since #94269. This deprecation is intended to help with symfony service locators (which we do not use), but would break our usecases once we update to symfony v6 as TYPO3 core and extensions rely on service_container autowiring for the PSR ContainerInterface alias. Releases: master Resolves: #94453 Related: #94269 Change-Id: I0599b3a8a5640faf2fac5094175ae2a6fb37a0a3 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69678 Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Benjamin Franzke <bfr@qbus.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Benjamin Franzke <bfr@qbus.de>
This is necessary as of Symfony 6.0 due to symfony/symfony#35879.
Defining those aliases makes it harder to detect problems when you use
!tagged_locator
or any service locator with autowiring since the global service container is always injected. Moreover, should we encourage passing the global service container easily? Shouldn't it be more "explicit"? I think that by default, those aliases should not exist.However, that means we will have to reintroduce code to hook the global service container in our own code base since some part rely on it (
eg: FWB AbstractController::setContainer). WDYT? 🤷♂