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] Fix autowiring tagged arguments from attributes#43579

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
nicolas-grekas merged 1 commit intosymfony:5.3fromokhoshi:fix-43272
Oct 26, 2021

Conversation

@okhoshi
Copy link
Contributor

@okhoshiokhoshi commentedOct 19, 2021
edited
Loading

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#43272
LicenseMIT
Doc PRno

Reimplement#40406 withAttributeAutoconfigurationPass to avoid the BC following the change inCompilerPass ordering inPassConfig.

Also revert the various fix made in an attempt to recover the BC introduced by#40406.

Note:5.4 branch was needed becauseAttributeAutoconfigurationPass is not handling parameters in 5.3

To-do:

BafS reacted with thumbs up emoji
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the titleFix 43272[DependencyInjection] Fix 43272Oct 19, 2021
@okhoshiokhoshiforce-pushed thefix-43272 branch 5 times, most recently from6a33b9b tob064ccaCompareOctober 19, 2021 21:47
@nicolas-grekas
Copy link
Member

Thanks for the PR, I think moving attributes resolution fromAutowirePass toAttributeAutoconfigurationPass is a nice approach.

Yet I see three issues that should be fixed to me:

  • this targets 5.4 while 5.3 is affected
  • this requires enabling autoconfiguration (as seen in patched tests)
  • this moves registering the attributes to FrameworkBundle (as seen in patched tests and highlighted by@stof).

I think all 3 issues can be solved by patchingAttributeAutoconfigurationPass on 5.3 so that it hardcodes a special behavior for those two attributes (they were already hardcoded inAutowirePass anyway.). This should allownot patching most test cases, which is desired.

@okhoshi
Copy link
ContributorAuthor

Thanks for the comments !

Is it possible to target 5.3 since theAttributeAutoconfigurationPass has drastically changed with 5.4 ? AFAIK, there's no logic to apply attributes from parameters, only on the classes.

When you say that you would hardcode the attributes in theAttributeAutoconfigurationPass, do you mean that you would register them in the$parameterAttributeConfigurators or that you would hardcode the transformation inprocessValue directly ?
As a personal taste, I would do the former, but it would still require enabling the autoconfiguration. By passing the autoconfiguration would likely require deep changes inAttributeAutoconfiguration.

As a side note, I had to change the behavior ofResolveInstanceofConditionalsPass to recursively resolve nested Definition (without that, one of the tests was not passing anymore).

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 20, 2021
edited
Loading

We need to fix this issue in 5.3, and I don't have a better idea.
We should not require autconfiguration to be enabled as that'd be a behavior change (booo scary BC breaks 👻).
It'd suggest starting with a copy/paste from 5.4 and then removing everything that is not strictly needed to fix this issue, while keeping the common parts as near as possible to ease merging up.

I had to change the behavior of ResolveInstanceofConditionalsPass to recursively resolve nested Definition

Yes, I didn't full grasp this part but I'll review more carefully after the rest is fixed :)

okhoshi and derrabus reacted with thumbs up emoji

@okhoshi
Copy link
ContributorAuthor

@nicolas-grekas I pushed a rework of the branch. It works with the IntegrationTest, but it breaks some tests on the side, mainly because theAttributeAutoconfigurationPass needs to run every time now (I spotted errors in the tests because getConstructor was called on a Definition for which the factory was not existing, not sure how I should handle that ?)

I'll fix the other tests tomorrow.

Also, I noticed that#43386 has been merged on 5.4 only and it's modifying the tags, so conflicts will arise :(.

@okhoshiokhoshi changed the base branch from5.4 to5.3October 20, 2021 21:33
@nicolas-grekasnicolas-grekas changed the title[DependencyInjection] Fix 43272[DependencyInjection] Fix autowiring tagged arguments from attributesOct 22, 2021
@nicolas-grekasnicolas-grekasforce-pushed thefix-43272 branch 4 times, most recently from9aa90b8 to55a39c0CompareOctober 22, 2021 17:26
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

While reviewing more carefully, I found that patchingAttributeAutoconfigurationPass would not work well with autowiring of@required methods, or with named arguments, etc.

Instead, I pushed a new pass that is dedicated to autowiring tagged arguments from attributes. This pass runs afterAutowireRequired*Pass and beforeServiceLocatorTagPass, thus fixing all concerns.

okhoshi reacted with thumbs up emoji
@nicolas-grekas
Copy link
Member

I figured out an even simpler patch, PR updated.

okhoshi, BafS, and fractalzombie reacted with hooray emoji

@nicolas-grekas
Copy link
Member

Thank you@okhoshi.

@nicolas-grekasnicolas-grekas merged commit97c32a1 intosymfony:5.3Oct 26, 2021
@okhoshiokhoshi deleted the fix-43272 branchOctober 26, 2021 08:32
@fabpotfabpot mentioned this pull requestOct 29, 2021
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

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

@stofstofAwaiting requested review from stof

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

[DependencyInjection] Non-existent "inner" service when decorated and autowired

5 participants

@okhoshi@carsonbot@nicolas-grekas@stof@derrabus

[8]ページ先頭

©2009-2025 Movatter.jp