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

Skip to content

[DependencyInjection] Fix alias chain inversion when deprecated alias points to decorated service#63160

Merged
nicolas-grekas merged 1 commit into
symfony:6.4from
amateescu:fix-deprecated-alias-chain-inversion
Jan 23, 2026
Merged

[DependencyInjection] Fix alias chain inversion when deprecated alias points to decorated service#63160
nicolas-grekas merged 1 commit into
symfony:6.4from
amateescu:fix-deprecated-alias-chain-inversion

Conversation

@amateescu
Copy link
Copy Markdown
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

When a service is decorated with a private decorator, and there is a deprecated alias pointing to the original service, the compiler passes could invert the alias chain. This caused the original service ID to become an alias pointing to the deprecated interface, triggering false deprecation warnings.

Two issues fixed:

  1. ResolveReferencesToAliasesPass was not preserving the deprecation flag when resolving alias chains
  2. ReplaceAliasByActualDefinitionPass used non-deterministic iteration order, allowing deprecated aliases to "win" when renaming definitions

Example scenario:

services:
  my_service:
    class: App\MyService

  App\MyServiceInterface:
    alias: my_service
    deprecated:
      package: 'my/package'
      version: '1.0'

  App\MyServiceDecorator:
    decorates: my_service
    public: false

Before fix: $container->get('my_service') would trigger deprecation warning
After fix: Only $container->get('App\MyServiceInterface') triggers deprecation warning

@nicolas-grekas
Copy link
Copy Markdown
Member

Good catch, thanks @amateescu.

@nicolas-grekas nicolas-grekas merged commit 158f8d9 into symfony:6.4 Jan 23, 2026
10 of 12 checks passed
@amateescu amateescu deleted the fix-deprecated-alias-chain-inversion branch January 23, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants