Skip to content
Permalink
Browse files

bug #27088 ResolveBindingsPass: Don't throw error for unused service,…

… missing parent class (weaverryan)

This PR was merged into the 3.4 branch.

Discussion
----------

ResolveBindingsPass: Don't throw error for unused service, missing parent class

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no->
| Tests pass?   | yes
| Fixed tickets | symfony/flex#346 (comment)
| License       | MIT
| Doc PR        | n/a

Hey guys!

In short: if you:

A) auto-register a class as a service
B) That class's parent class is missing
C) ... but this class/service is unused

Currently, `ResolveBindingsPass` will fail and throw an exception. The change avoids that - only throwing the exception if the service IS used. This is already done in `AutowirePass`.

The real issue is DoctrineFixturesBundle, where, on production, the bundle (and so, `Fixtures` base class) is not installed, causing a build error, even though these service classes are unused.

Cheers!

Commits
-------

309da92 Avoiding an error when an unused service has a missing base class
  • Loading branch information...
nicolas-grekas committed Apr 30, 2018
2 parents 7242b4c + 309da92 commit 45fd7f8a8e807d85a715aa33b01bbd89fa8fac76
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php
@@ -15,6 +15,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
use Symfony\Component\DependencyInjection\TypedReference;
use Symfony\Component\DependencyInjection\Reference;
@@ -88,8 +89,14 @@ protected function processValue($value, $isRoot = false)
$calls = $value->getMethodCalls();
if ($constructor = $this->getConstructor($value, false)) {
$calls[] = array($constructor, $value->getArguments());
try {
if ($constructor = $this->getConstructor($value, false)) {
$calls[] = array($constructor, $value->getArguments());
}
} catch (RuntimeException $e) {
$this->container->getDefinition($this->currentId)->addError($e->getMessage());
return parent::processValue($value, $isRoot);
}
foreach ($calls as $i => $call) {

0 comments on commit 45fd7f8

Please sign in to comment.
You can’t perform that action at this time.