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

[DI] Do not process bindings in AbstractRecursivePass#24602

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
fabpot merged 1 commit intosymfony:3.4fromchalasr:add-bindings-to-object-graph
Oct 18, 2017

Conversation

@chalasr
Copy link
Member

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#24559
LicenseMIT
Doc PRn/a

@chalasr
Copy link
MemberAuthor

Build failure unrelated.

@dmaicher
Copy link
Contributor

Does this mean that in the example mentioned in#24559 the inlinedbar service is not removed anymore withinRemoveUnusedDefinitionsPass with this fix?

@chalasr
Copy link
MemberAuthor

@dmaicher yes

@dmaicher
Copy link
Contributor

👍 Should it not be merged into 3.4 instead of master?

@chalasrchalasr changed the base branch frommaster to3.4October 18, 2017 10:01
@chalasrchalasrforce-pushed theadd-bindings-to-object-graph branch from79c4875 to98cb64fCompareOctober 18, 2017 10:36
@stof
Copy link
Member

Are you sure about it ? Bindings are used by the autowiring layer, which runsbefore the removal passes. If the autowiring has not used the binding to set a reference, we don't have a usage (and we don't need to prevent removal AFAIK). And if the binding was used to fill an argument, we will have a reference in the arguments (and so processed by the existing code)

@dmaicher
Copy link
Contributor

And if the binding was used to fill an argument, we will have a reference in the arguments (and so processed by the existing code)

@stof if the service was inlined this it not true I believe. It will have an inlinedDefinition in the arguments and not aReference.

@stof
Copy link
Member

@dmaicher and this is fine as well, as the argument is still filled properly. It does not need the binding anymore.

Actually, I think the issue is that AbstractRecursivePass is always processing bindings in the exact same way it processes arguments, method calls and so on.
And so, it will treat any reference in a binding as a usage of the service. But once bindings are used to fill arguments, they become useless. So they should not be visited by the validator passes checking for circular references, invalid references and so on.
I'm not even sure there is a single case where a recursive pass should visit them.

@dmaicher
Copy link
Contributor

@stof ok I see 😉 Then we should indeed not check the References contained in bindings I guess. So the Definitions can be removed correctly for inlined services.

@chalasrchalasrforce-pushed theadd-bindings-to-object-graph branch from98cb64f tod86f126CompareOctober 18, 2017 10:55
@chalasrchalasr changed the title[DI] Detect references from bound arguments when populating the object graph[DI] Do not process bindings in AbstractRecursivePassOct 18, 2017
@chalasrchalasrforce-pushed theadd-bindings-to-object-graph branch 2 times, most recently from72ffcb1 tob175419CompareOctober 18, 2017 11:07
@chalasr
Copy link
MemberAuthor

PR updated to not process bindings in AbstractRecursivePass.

$value->setArguments($this->processValue($value->getArguments()));
$value->setProperties($this->processValue($value->getProperties()));
$value->setMethodCalls($this->processValue($value->getMethodCalls()));
$value->setBindings($this->processValue($value->getBindings()));
Copy link
Contributor

@dmaicherdmaicherOct 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

can we have a test case for this?for example within theRemoveUnusedDefinitionsPassTest?

Copy link
Contributor

@dmaicherdmaicherOct 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

Sorry I mean the test for the pass that checks if services exist ;p

==>CheckExceptionOnInvalidReferenceBehaviorPassTest

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Test added

@chalasrchalasrforce-pushed theadd-bindings-to-object-graph branch 2 times, most recently from6b2282f to148bdecCompareOctober 18, 2017 12:09
{
$container =newContainerBuilder();

$container->register('a','stdClass');
Copy link
Contributor

@dmaicherdmaicherOct 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

this test will now also pass without your change I believe? we should remove this line so the Referencea in the bindings does actually not exist on the container?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

oops :) fixed

@chalasrchalasrforce-pushed theadd-bindings-to-object-graph branch from148bdec to6a6256cCompareOctober 18, 2017 12:27
@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commit6a6256c intosymfony:3.4Oct 18, 2017
fabpot added a commit that referenced this pull requestOct 18, 2017
…lasr)This PR was merged into the 3.4 branch.Discussion----------[DI] Do not process bindings in AbstractRecursivePass| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#24559| License       | MIT| Doc PR        | n/aCommits-------6a6256c Do not process bindings in AbstractRecursivePass
@chalasrchalasr deleted the add-bindings-to-object-graph branchOctober 18, 2017 14:17
nicolas-grekas added a commit that referenced this pull requestNov 7, 2017
This PR was merged into the 3.4 branch.Discussion----------[DI] Fix cannot bind env var| Q             | A| ------------- | ---| Branch?       | 3.4 <!-- see comment below -->| Bug fix?      | yes| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets |#24845 <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | N/AIn#24602 we removed the processing of bindings from the `AbstractRecursivePass`. But there is actually one case where we want a recursive pass to process them: to resolve env param placeholders.Commits-------f8f3a15 [DI] Fix cannot bind env var
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+2 more reviewers

@dmaicherdmaicherdmaicher approved these changes

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

7 participants

@chalasr@dmaicher@stof@fabpot@nicolas-grekas@ogizanagi@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp