Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DI] Shared services should not be inlined in non-shared ones#27265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…nes (nicolas-grekas)This PR was merged into the 3.4 branch.Discussion----------[DI] Shared services should not be inlined in non-shared ones| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -[Already good on 2.7/2.8.](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php#L152)Commits-------6f8b862 [DI] Shared services should not be inlined in non-shared ones
| } | ||
| returntrue; | ||
| return$this->container->getDefinition($ids[0])->isShared(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Look like this change break the compilation withUndefined offset: 0 when the node doesn't have anyInEdges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
hotfixed in5eb17e5
but I don't understand how this can happen logically (we're here because we did find a reference to the service, to it must have at least one in-edge.)
could you share a reproduder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The use case is: I use a custom TestKernel which inject mocks in the container and set the service as Synthetic with a compiler pass
NB: Changing the type of the compiler pass toPassConfig::TYPE_AFTER_REMOVING (to run afterInlineServiceDefinitionsPass) fix the issue
This minimal reproduct case is:
class Kernel extends BaseKernel implements CompilerPassInterface{ // ... public function process(ContainerBuilder $container) { // routing.resolver is just an example for the minimal reproduct case here $container->getDefinition('routing.resolver')->setPublic(true)->setSynthetic(true); }}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ok, so this means we are missing a check for synthetic service!
added in#27366
Uh oh!
There was an error while loading.Please reload this page.
Already good on 2.7/2.8.