Skip to content

Commit

Permalink
bug #28512 [DI] fix infinite loop involving self-references in decora…
Browse files Browse the repository at this point in the history
…ted 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
-------

20f27f9 [DI] fix infinite loop involving self-references in decorated services
  • Loading branch information
nicolas-grekas committed Sep 19, 2018
2 parents 8877a33 + 20f27f9 commit e0e5e83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -113,6 +113,8 @@ protected function processValue($value, $isRoot = false)
return $value;
}
$this->currentDefinition = $value;
} elseif ($this->currentDefinition === $value) {
return $value;
}
$this->lazy = false;

Expand Down
Expand Up @@ -1479,6 +1479,22 @@ public function testUninitializedSyntheticReference()
$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
Expand Down

0 comments on commit e0e5e83

Please sign in to comment.