Skip to content

Commit

Permalink
bug #22376 [FrameworkBundle] Use findDefinition() instead of getDefin…
Browse files Browse the repository at this point in the history
…ition() on aliases (chalasr)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Use findDefinition() instead of getDefinition() on aliases

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

The services for which `has()` is called might be aliases at this point so `getDefinition()` gives an exception, I ran into by executing this pass but not the removing ones (skipping ReplaceAliasByActualDefinitionPass) while working on #16388. Let's make it safe to use independently.

Commits
-------

41f3d1f Use findDefinition() instead of getDefinition() after calling has()
  • Loading branch information
fabpot committed Apr 11, 2017
2 parents a6dbc39 + 41f3d1f commit e904ab8
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -56,14 +56,14 @@ public function process(ContainerBuilder $container)
return;
}
$factory = array(AbstractAdapter::class, 'createSystemCache');
$annotationsPool = $container->getDefinition('cache.annotations');
$annotationsPool = $container->findDefinition('cache.annotations');
if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
return;
}
if ($container->has('monolog.logger.cache')) {
$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
} elseif ($container->has('cache.system')) {
$systemPool = $container->getDefinition('cache.system');
$systemPool = $container->findDefinition('cache.system');
if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
$annotationsPool->addArgument($systemArgs[4]);
}
Expand Down

0 comments on commit e904ab8

Please sign in to comment.