Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Conversation

fancyweb
Copy link
Contributor

@fancywebfancyweb commentedFeb 26, 2020
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
Deprecations?yes
Tickets-
LicenseMIT
Doc PR-

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? 🤷‍♂

dmaicher and Koc reacted with hooray emoji
@michaljusiega
Copy link
Contributor

Will there be a replacement option?

@fancyweb
Copy link
ContributorAuthor

Yes, you would have to define those aliases in your project.

@nicolas-grekas
Copy link
Member

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)

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.)

@michaljusiega
Copy link
Contributor

Yes, you would have to define those aliases in your project.

So, please show me a small example because I'm not sure of these changes ... and if it works, why remove it?

@fancyweb
Copy link
ContributorAuthor

I'm not sure what you mean here: AbstractController is a service subscriber, it doesn't use the main container.

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.

So, please show me a small example because I'm not sure of these changes ...

For example, in YAML:

Psr\Container\ContainerInterface:alias:"service_container"

Checkhttps://symfony.com/doc/current/service_container/alias_private.html#aliasing.

and if it works, why remove it?

For the reasons I described in the PR description.

@nicolas-grekasnicolas-grekas added this to thenext milestoneFeb 27, 2020
@nicolas-grekas
Copy link
Member

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

That shouldn't be the case - we don't use autowiring in core. Did you find any?

@fancywebfancywebforce-pushed thedi-deprecate-service-container-aliases branch 2 times, most recently from8225445 to76172b8CompareFebruary 28, 2020 11:53
@@ -148,6 +152,9 @@ private function createContainer($sessionStorageOptions)
$pass = new AddSessionDomainConstraintPass();
$pass->process($container);

$container->setDefinition('.service_subscriber.fallback_container', new Definition(Container::class));
Copy link
ContributorAuthor

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.

@fancywebfancywebforce-pushed thedi-deprecate-service-container-aliases branch from76172b8 to42fe4fcCompareMarch 26, 2020 14:11
@nicolas-grekas
Copy link
Member

Rebase needed.
Ping @symfony/mergers meanwhile.

@fancyweb
Copy link
ContributorAuthor

TODO: waiting for#36295 because tests can't pass atm.

@fancywebfancywebforce-pushed thedi-deprecate-service-container-aliases branch from42fe4fc to6162ca8CompareApril 1, 2020 07:33
@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull requestJul 1, 2021
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>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull requestJul 1, 2021
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>
mpdude added a commit to mpdude/FriendsOfBehat_SymfonyExtension that referenced this pull requestNov 24, 2022
This is necessary as of Symfony 6.0 due tosymfony/symfony#35879.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dmaicherdmaicherdmaicher left review comments

Assignees
No one assigned
Projects
None yet
Milestone
5.1
Development

Successfully merging this pull request may close these issues.

5 participants
@fancyweb@michaljusiega@nicolas-grekas@dmaicher@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp