Skip to content

[DependencyInjection] Fix circular reference in autowired decorators #42815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2021
Merged

[DependencyInjection] Fix circular reference in autowired decorators #42815

merged 1 commit into from
Sep 1, 2021

Conversation

shyim
Copy link
Contributor

@shyim shyim commented Aug 31, 2021

Q A
Branch? 5.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #42791
License MIT
Doc PR

As the Decorator pass runs after the Autowire, the innerServiceId was always empty. I have changed that to getDecoratedService and added a test with the given example in the issue.

@shyim shyim requested a review from dunglas as a code owner August 31, 2021 16:52
@carsonbot carsonbot added this to the 5.3 milestone Aug 31, 2021
@carsonbot carsonbot changed the title [DI] Fix circular reference in autowired decorators [DependencyInjection] Fix circular reference in autowired decorators Aug 31, 2021
try {
(new AutowirePass())->process($container);
$this->fail('AutowirePass should have thrown an exception');
} catch (AutowiringFailedException $e) {
$this->assertSame('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator": argument "$decorated1" of method "__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DecoratorInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator", "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator.inner".', (string) $e->getMessage());
$this->assertSame('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator": argument "$decorated1" of method "__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DecoratorInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Symfony\Component\DependencyInjection\Tests\Compiler\Decorated", "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator".', (string) $e->getMessage());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that so okay? As the DecoratorPass did not run until this point the .inner does not exists yet 😅

@shyim
Copy link
Contributor Author

shyim commented Aug 31, 2021

The fabbot wants unreleated change which looks wrong 😅
https://fabbot.io/report/symfony/symfony/42815/b21e709d250e7eb22f9a900cf6dc9d93ab13a6de

Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the issue on my side

@fabpot
Copy link
Member

fabpot commented Sep 1, 2021

Thank you @shyim.

@fabpot fabpot merged commit 0d46efc into symfony:5.3 Sep 1, 2021
@mbrodala
Copy link
Contributor

Just to be sure: will there be a version 5.3.8 with this fix before 5.4? ATM we are unable to update to 5.3.7 due to this error.

@derrabus
Copy link
Member

yes

Okhoshi added a commit to Okhoshi/symfony that referenced this pull request Oct 19, 2021
Okhoshi added a commit to Okhoshi/symfony that referenced this pull request Oct 20, 2021
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.

7 participants