-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Symfony version(s) affected
5.4.16, 6.0.16, 6.1.8, 6.2.0
Description
With the changes from #48027 empty tags get swallowed if a non-empty tag with the same name already exists. This causes issues because empty tags sometimes have a different meaning like with the container.service_subscriber
tag.
The tag that gets set in
symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Lines 540 to 541 in 205cb5a
$container->registerForAutoconfiguration(ServiceSubscriberInterface::class) | |
->addTag('container.service_subscriber'); |
symfony/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php
Line 88 in 205cb5a
throw new InvalidArgumentException(sprintf('Service "%s" misses a "container.service_subscriber" tag with "key"/"id" attributes corresponding to entry "%s" as returned by "%s::getSubscribedServices()".', $this->currentId, $key, $class)); |
The container.service_subscriber
tag has a different meaning if it is empty as we can see in:
symfony/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php
Line 43 in 205cb5a
if (!$attributes) { |
How to reproduce
services:
_instanceof:
Some\Vendor\Interface:
tags:
- { name: container.service_subscriber, id: my.id }
- { name: container.service_subscriber }
(the second tag does not get applied)
Possible Solution
Revert #48027 and solve #48019 differently.
Additional Context
No response