Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DependencyInjection] Tagged services with negative priority #50900

Copy link
Copy link
Closed
@Phenix789

Description

@Phenix789
Issue body actions

Symfony version(s) affected

6.3

Description

By upgrading from 6.2 to 6.3, services implemente an registerForAutoconfiguration() interface with negative priority are not sorted correctly.
This seems happen only when $needsIndexes is set to true (see below).

How to reproduce

  1. Define a tagged service with a negative priority
$services
  ->set(MyService::class)->tag('controller.argument_value_resolver', ['priority' => -70]);
  1. ValueResolverInterface is registerForAutoconfiguration
  2. Now ControllerArgumentValueResolverPass call findAndSortTaggedServices() with a TaggedIteratorArgument and $needsIndexes to true instead of a simple string.
    The behavior of this method is changed and instead of register service only once by continue 2, the service is registered twice one with -70 priority and one with 0 priority.
  3. uasort() sort the service with priority 0 before the -70 one (normal)
  4. The $refs construction add the priority 0 first and the -70 only rewrite it.

Possible Solution

Locally, I need to register my service with autoconfigure(false).

$services
  ->set(MyService::class)->autoconfigure(false)->tag('controller.argument_value_resolver', ['priority' => -70]);

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.