Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] Empty tags get lost in instanceof conditionals #48388

Closed
@HypeMC

Description

@HypeMC

Symfony version(s) affected

v5.4.16

Description

Symfony v5.1.16 has introduced a BC break in how autoconfiguring works. The issue was caused by #48027 .

How to reproduce

#[AutoconfigureTag('app.foo')]
interface FooInterface
{
}

#[AutoconfigureTag('app.foo', ['alias' => 'bar'])]
class Foo implements FooInterface
{
}
app.foo_locator:
    class: Symfony\Component\DependencyInjection\ServiceLocator
    arguments: [ !tagged_iterator { tag: 'app.foo', index_by: 'alias' } ]

Before #48027 the app.foo_locator service locator would have 2 aliases for the Foo service (which is the behavior I need):

return $container->services['app.foo_locator'] = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [
    'App\\Service\\Foo' => ['privates', 'App\\Service\\Foo', 'getFooService', true],
    'bar' => ['privates', 'App\\Service\\Foo', 'getFooService', true],
], [
    'App\\Service\\Foo' => 'App\\Service\\Foo',
    'bar' => 'App\\Service\\Foo',
]);

After upgrading to v5.4.16, this is no longer the case:

return $container->services['app.foo_locator'] = new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($container->getService, [
    'bar' => ['privates', 'App\\Service\\Foo', 'getFooService', true],
], [
    'bar' => 'App\\Service\\Foo',
]);

Since the Foo service has an #[AutoconfigureTag] attribute, the FooInterface is skipped during autoconfiguration.

Possible Solution

No response

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