8000 [DI] Empty tags get lost in instanceof conditionals · Issue #48404 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DI] Empty tags get lost in instanceof conditionals #48404
Closed
@ausi

Description

@ausi

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

$container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
->addTag('container.service_subscriber');
is skipped by this if there is an existing non-empty tag wich causes the following exception:
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:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0