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] check for circular refs caused by method calls#21642

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

Closed
xabbuh wants to merge1 commit intosymfony:2.7fromxabbuh:issue-19362

Conversation

@xabbuh
Copy link
Member

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#19362
LicenseMIT
Doc PR

@xabbuh
Copy link
MemberAuthor

Tests pass onmaster too now (seehttps://travis-ci.org/symfony/symfony/builds/202523603) thanks to the changes@nicolas-grekas made in#21639.

;

$container
->register('foo','\stdClass')
Copy link
Contributor

Choose a reason for hiding this comment

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

should bebar no?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

indeed, good catch

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it weird the tests still passed with that?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Well, a circular reference is still a circular reference. I just wanted to explicitly have one with an intermediate service.

$instance->setFoo($this->get('foo_with_inline'));

return$instance;
return$this->services['baz'] =new \Baz();
Copy link
Member

Choose a reason for hiding this comment

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

This was a case where the circular reference wasworking, as the service can be instantiated and registered in $this->services before the point triggering the call to the other service, meaning it will receive the instance.
Forbidding a case which was working previously is a BC break. So this is not acceptable, especially for a patch release

@stof
Copy link
Member

-1 for this PR as is. It removes a supported feature. Tests are passing now because you remove the test ensuring that this feature keeps working

jvasseur reacted with thumbs up emoji

@stof
Copy link
Member

And given the potential to break existing projects, should we really merge this again in a patch release ? Our latest releases already have a BC break because of this.

@theofidry
Copy link
Contributor

theofidry commentedFeb 17, 2017
edited
Loading

@xabbuh tbh I fail to see how this circular dependency is a problem in the first place, it sure can be a big smell, but it's a legitimate thing as well. For example if you have:

class X {private$y;  setY(self$y) {$this->y =$y;  }}$x1 =newX();$x2 =newX();$x1->setY($x2);$x2->setY($x1);

it's perfectly ok in PHP, I don't see why you shouldn't be able to do this with the DIC. There is legitimate use cases for it (I don't have on top of my head though soz)

@xabbuh
Copy link
MemberAuthor

Our latest releases already have a BC break because of this.

@stof I don't know what you mean. The commit that reverted the previous PR (68d6415) was part of the 3.2.4 release.

@stof
Copy link
Member

@xabbuh see my comment in the issue giving more details about the work needed. This PR as is is not the right fix (it has false positives, which are worse than false negatives)

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneFeb 18, 2017
@xabbuh
Copy link
MemberAuthor

Closing as this is not the solution for the problem. But we still have#19362 that reminds us of the real issue.

@xabbuhxabbuh closed thisApr 3, 2017
@xabbuhxabbuh deleted the issue-19362 branchApril 3, 2017 10:11
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof requested changes

+1 more reviewer

@theofidrytheofidrytheofidry left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@xabbuh@stof@theofidry@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp