Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[DependencyInjection] Deprecate ContainerInterface aliases#35879
Uh oh!
There was an error while loading.Please reload this page.
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" Checkhttps://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? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
8225445
to76172b8
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 theRegisterServiceSubscribersPass
pass is not executed. Consequently, services that havePsr\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
to42fe4fc
CompareRebase needed. |
TODO: waiting for#36295 because tests can't pass atm. |
42fe4fc
to6162ca8
CompareThank you@fancyweb. |
Account for the symfony deprecation insymfony/symfony#35879which deprecated the default alias for Psr\Container\ContainerInterfaceand 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 tosymfony v6 as TYPO3 core and extensions rely on service_containerautowiring for the PSR ContainerInterface alias.Releases: masterResolves: #94453Related: #94269Change-Id: I0599b3a8a5640faf2fac5094175ae2a6fb37a0a3Reviewed-on:https://review.typo3.org/c/Packages/TYPO3.CMS/+/69678Tested-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 insymfony/symfony#35879which deprecated the default alias for Psr\Container\ContainerInterfaceand 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 tosymfony v6 as TYPO3 core and extensions rely on service_containerautowiring for the PSR ContainerInterface alias.Releases: masterResolves: #94453Related: #94269Change-Id: I0599b3a8a5640faf2fac5094175ae2a6fb37a0a3Reviewed-on:https://review.typo3.org/c/Packages/TYPO3.CMS/+/69678Tested-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 tosymfony/symfony#35879.
Uh oh!
There was an error while loading.Please reload this page.
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? 🤷♂