Skip to content

Commit 6fe4a48

Browse files
authored
Catch exceptions when resolving classes
When any service (in my case provided by hwi-oauth-bundle) has a parameterized class (`%foo.bar.baz%`) this bundle here crashes hard and makes the application unusable. This stems from the fact, that the parameter value is not available during compile time that early (this compiler pass runs with priority 110). We now silently skip over all services that have a non-resolvable class name.
1 parent 114105f commit 6fe4a48

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/DependencyInjection/Compiler/ServiceAnnotationPass.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ public function process(ContainerBuilder $container): void
3737
$class = $id;
3838
}
3939

40-
$class = $container->getParameterBag()->resolveValue($class);
40+
try {
41+
$class = $container->getParameterBag()->resolveValue($class);
42+
} catch (\Throwable $exception) {
43+
// This is not processable - potentially problem with other bundles that register services with parameters as class name.
44+
// The parameter might not be available yet, as we are registered with priority 110.
45+
continue;
46+
}
4147

4248
if (
4349
!$class

0 commit comments

Comments
 (0)