-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Fixed case where service definition is actually an alias #5000
Conversation
if (!$container->hasDefinition('acme_mailer.transport_chain')) { | ||
try { | ||
$definition = $container->findDefinition('acme_mailer.transport_chain'); | ||
} catch (\InvalidArgumentException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather just call has()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has()
/ get()
methods should be used instead yeah. But anyhow, I think this shouldn't be left like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the code accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @xabbuh
5000 PR 🎉 |
return; | ||
} | ||
|
||
$definition = $container->getDefinition( | ||
$definition = $container->get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't use get()
in a compiler pass (the definition may be modified by other passes). Use findDefinition()
instead.
Added exception catch Changed methods used Revert
👍 |
🎉 |
Wow, this is really subtle! Very nice catch @xavismeh! Ok, we're half way to 10,000. Let's get to work! ;) |
…avier Coureau) This PR was merged into the 2.3 branch. Discussion ---------- Fixed case where service definition is actually an alias If `acme_mailer.transport_chain` service would be an alias, the `hasDefinition` method would return `false` and would fake the expected result. Same for the further call on `getDefinition` method. Commits ------- c9caef6 Fixed case where definition service is an alias
If
acme_mailer.transport_chain
service would be an alias, thehasDefinition
method would returnfalse
and would fake the expected result.Same for the further call on
getDefinition
method.