-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DependencyInjection] Fixed factory service not within the ServiceReferenceGraph. #11639
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
Conversation
@stof should I add the following test to public function testPrivateFactoryRemoved()
{
$container = new ContainerBuilder();
$container
->register('foo', 'Bar\\FooClass')
->setFactoryClass('Bar\\FooClass')
->setFactoryMethod('getInstance')
->setPublic(false);
$container
->register('bar', 'Bar\\FooClass')
->setFactoryService('foo')
->setFactoryMethod('getInstance')
->setPublic(false);
$container
->register('foobar')
->addArgument(new Reference('bar'));
$this->process($container);
$this->assertTrue($container->hasDefinition('foo'));
$this->assertTrue($container->hasDefinition('bar'));
$this->assertTrue($container->hasDefinition('foobar'));
} |
looks like a good idea (except the test name as it is checking that the factory service is not removed) |
Added |
@stof is there anything else I can do to get this merged? |
👍 |
This should be done outside the |
note to maintainers: this should go in 2.3 |
@stof should I do a rebase based on the 2.3 branch? |
@boekkooi no, we will do it when merging. If you rebase now, the PR diff will show all 2.3 commits which have not yet been merged in master. Regarding the circular reference, there is a check using an analysis based only on the constructor arguments (to check it at compile time rather than at runtime for things where we can detect that it will be a circular reference issue in all case). The factory service is one of these cases: we need the factory service before instantiating the service (given that it is the one doing the instantiation), so it will always trigger a circular reference even if we inline some stuff. |
2d867b9
to
0297562
Compare
0297562
to
534cdc6
Compare
@stof Great information! Thanks! The circular reference tests has been added and the if statement is moved (else the test fails), also did a rebase. |
@stof but we do have a BC break. Before you could define a circular reference between factory services and it was allowed but would throw a exception when called at runtime (if it was ever called). Should this "minor" BC break be documented some where? |
so you mean defining broken servces but not using them ? I don't think this needs to have BC preserved IMO. |
👍 |
Good catch, thanks @boekkooi. |
… ServiceReferenceGraph. (boekkooi) This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11639). Discussion ---------- [DependencyInjection] Fixed factory service not within the ServiceReferenceGraph. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Fixed a problem where Factory services are not added to the ServiceReferenceGraph. Commits ------- e992f8e Fixed Factory services not within the ServiceReferenceGraph.
Fixed a problem where Factory services are not added to the ServiceReferenceGraph.