Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Fix circular reference with Factory + Lazy Iterrator#38980
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
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Uh oh!
There was an error while loading.Please reload this page.
95fe676 to6651366Compare6651366 to51ff060Comparenicolas-grekas approved these changesNov 4, 2020
Member
nicolas-grekas commentedNov 5, 2020
Thank you@jderusse. |
Merged
derrabus added a commit that referenced this pull requestNov 12, 2020
… paths (jderusse)This PR was merged into the 4.4 branch.Discussion----------[DependencyInjection] Fix circular detection with multiple paths| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#39056| License | MIT| Doc PR | -There are currently 2 kind of issues related to the Dependency Injection:1. performance issue when project contains many loops (#37850)Which has been fixed by#388822. Infinity loop in some case (#38970)Which has been fixed by#38980 and#39021The new issue#39056 has been introduced by#38882 (The performance issue refactor) because in order to optimize loop detection, I take a short cut and choose to not collect ALL the circular loop but only the one that mattersI was wrong. All loops matters.This PR fix my previous refacto to collect ALL the paths, with a low CPU footprintCommits-------1c3721e Fix circular detection with multiple paths
This was referencedNov 20, 2020
nicolas-grekas added a commit that referenced this pull requestNov 27, 2020
…truct loop (jderusse)This PR was squashed before being merged into the 4.4 branch.Discussion----------[DependencyInjection] Fix circular in DI with lazy + byContruct loop| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#39120| License | MIT| Doc PR | -This fix another issue lazy service.It partially revert#38980 and#39021Initially, we trusted lazy services to be lazy and not beeing called while building the services graph=> bug#38970 when lazy deps is injected in a factory, it may be consumed directly to build the object before the graph is fully builtFixed by#38980 => lazy service are considered as "normal service"=> bug#39015 some loop are not resolvable with "normal service", but it shouldn't be an issue when servie proxifyiedFixed by#39021 => lazy service are considered as "normal service" except when proxyfied=> bug#39120 some loop are not resolvable with "normal service", but it shouldn't be an issue because the lazy service is injected in the constructor and userFixed by this PR => that revert to the initial state. lazy service are trusted.But now, The IterratorArgument injected in a factory (single exception) is not more considered as lazyCommits-------54af139 [DependencyInjection] Fix circular in DI with lazy + byContruct loop
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue, occurs when a
factoryiterates over services (think tagged iterator) that also need thefactory.The PhpDumper is not able to detect the loop because the TaggedService iterator is flaged as "lazy" which is ignored in the loop detection.
symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Lines 474 to 476 in2d7e0b0
See test case for a reproduce case.
This PR takes into account lazy services when computing loops.
I'm not sure this is the right thing to do /cc@nicolas-grekas .
A better solution could be to do this ONLY when the service is used as a factory?