-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] A decorated service should not keep the autowiring types #20267
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DependencyInjection] A decorated service should not keep the autowiring types #20267
Conversation
549eb14
to
3289181
Compare
3289181
to
01d4383
Compare
Status: Reviewed 👍 |
This patch is for parent/child definitions. Do we have the same issue for service decoration (as handled in the |
@xabbuh This patch concerns service decoration, not parent/child (abstract services). In fact the Here we are explicitly ignoring abstract services, because only decorated services (corresponding to Applying this patch to parent/child definitions (removing autowiring types from the abstract parent def) would mean that only the first child of the abstract service inherit the autowiring types, that is not what we want. Note that this issue is very specific to autowiring types. |
5343373
to
a1b0814
Compare
Failed builds are unrelated (Twig). |
@@ -57,6 +57,7 @@ public function process(ContainerBuilder $container) | ||
$public = $decoratedDefinition->isPublic(); | ||
$decoratedDefinition->setPublic(false); | ||
$decoratedDefinition->setTags(array()); | ||
$decoratedDefinition->setAutowiringTypes(array()); |
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.
I think we should first add the old value to the decorating service. What do you think?
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.
Indeed, done
@@ -142,6 +142,25 @@ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinitio | ||
$this->assertEquals(array('name' => 'bar'), $container->getDefinition('baz')->getTags()); | ||
} | ||
|
||
public function testDecoratedServiceLoosesAutowiringTypes() |
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.
loses
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.
fixed
c43301e
to
963d0c5
Compare
963d0c5
to
5951378
Compare
Thank you @chalasr. |
…the autowiring types (chalasr) This PR was merged into the 2.8 branch. Discussion ---------- [DependencyInjection] A decorated service should not keep the autowiring types | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20260 (comment) | License | MIT | Doc PR | n/a When decorating a service which is not abstract and has `autowiring_types`, the decorator should be the one used for autowiring methods of autowired services, so we should explicitly empty them on the decorated definition after merged them into the child. See #20260 (comment) for a use case where we are forced to manually empty the decorated service's `autowiring_types`. Commits ------- 5951378 A decorated service should not keep the autowiring types
When decorating a service which is not abstract and has
autowiring_types
, the decorator should be the one used for autowiring methods of autowired services, so we should explicitly empty them on the decorated definition after merged them into the child. See #20260 (comment) for a use case where we are forced to manually empty the decorated service'sautowiring_types
.