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

Skip to content

[DependencyInjection] Fix issue between decorator and service locator index #58000

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

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Aug 13, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #53174
License MIT

This PR is not finished yet. I want to gather feedback before writing tests.

To explain what is wrong, I create a reproducer.

Basically, when we decorates a services, we replace the old ID with a new ID in the DIC.

Then, when we build a service locator, we use the new ID. This is really not handy because our code
is dependant on the new name or old name, depending if the decorator is here or not!

This issue discribe very well the issue: #53174

So in this PR, I save the original ID in the decorator definition. Then I used this initial ID to build the $index of the
service locator.


With this PR and the reproducer, I got what would be expected

image

  • Original ID in the locator
  • But we retrieve the decorated
  • Works well with decorator of decorator (etc)

@carsonbot carsonbot added this to the 5.4 milestone Aug 13, 2024
lyrixx added a commit to lyrixx/test that referenced this pull request Aug 13, 2024
lyrixx added a commit to lyrixx/test that referenced this pull request Aug 13, 2024
@lyrixx lyrixx force-pushed the dic-decorator-locator branch from 96f9ae7 to 39b216d Compare August 13, 2024 14:56
@nicolas-grekas
Copy link
Member

The patch is nice, but in 6.4, we already have infrastructure in place to pass the inner around, see #49625 and #50710.

Can't we leverage this? Or backport if that's needed for the fix on 5.4?

@lyrixx
Copy link
Member Author

lyrixx commented Aug 21, 2024

@nicolas-grekas Thanks for the review ; ✅

@lyrixx lyrixx force-pushed the dic-decorator-locator branch from 8a842cb to b2e8399 Compare August 21, 2024 14:41
@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit 86ccbdb into symfony:5.4 Aug 21, 2024
11 of 12 checks passed
@lyrixx lyrixx deleted the dic-decorator-locator branch August 21, 2024 16:01
This was referenced Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants