Skip to content

Commit 928c1d6

Browse files
committed
bug symfony#18730 [FrameworkBundle] prevent calling get() for service_container service (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle] prevent calling get() for service_container service | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This change will simply fix the tests once symfony#18728 gets merged. An alternative approach would be to compile the container so that the code would still work even for services that have been set directly using `set()`. However, compiling the container in a descriptor imo is an unexpected side effect which I tried to avoid here. Commits ------- 2d46bd4 prevent calling get() for service_container service
2 parents 17e2911 + 2d46bd4 commit 928c1d6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI
274274
return $builder->getAlias($serviceId);
275275
}
276276

277+
if ('service_container' === $serviceId) {
278+
return $builder;
279+
}
280+
277281
// the service has been injected in some special way, just return the service
278282
return $builder->get($serviceId);
279283
}

0 commit comments

Comments
 (0)