bug #28512 [DI] fix infinite loop involving self-references in decorated services (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[DI] fix infinite loop involving self-references in decorated services
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #28510
| License | MIT
| Doc PR | -
Commits
-------
20f27f9c72
[DI] fix infinite loop involving self-references in decorated services
This commit is contained in:
commit
e0e5e83732
@ -113,6 +113,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
||||
return $value;
|
||||
}
|
||||
$this->currentDefinition = $value;
|
||||
} elseif ($this->currentDefinition === $value) {
|
||||
return $value;
|
||||
}
|
||||
$this->lazy = false;
|
||||
|
||||
|
@ -1479,6 +1479,22 @@ class ContainerBuilderTest extends TestCase
|
||||
$container->set('foo', (object) array(123));
|
||||
$this->assertEquals((object) array('foo' => (object) array(123)), $container->get('bar'));
|
||||
}
|
||||
|
||||
public function testDecoratedSelfReferenceInvolvingPrivateServices()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(false)
|
||||
->setProperty('bar', new Reference('foo'));
|
||||
$container->register('baz', 'stdClass')
|
||||
->setPublic(false)
|
||||
->setProperty('inner', new Reference('baz.inner'))
|
||||
->setDecoratedService('foo');
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertSame(array('service_container'), array_keys($container->getDefinitions()));
|
||||
}
|
||||
}
|
||||
|
||||
class FooClass
|
||||
|
Reference in New Issue
Block a user