[DI] fix infinite loop involving self-references in decorated services
This commit is contained in:
parent
8877a338a8
commit
20f27f9c72
@ -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