Skip to content
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

Merged
merged 1 commit into from
Mar 2, 2015
Merged

Fixed case where service definition is actually an alias #5000

merged 1 commit into from
Mar 2, 2015

Conversation

xavismeh
Copy link

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.

@xavismeh xavismeh changed the title Fixed case where definition service is an alias Fixed case where service definition is actually an alias Feb 16, 2015
if (!$container->hasDefinition('acme_mailer.transport_chain')) {
try {
$definition = $container->findDefinition('acme_mailer.transport_chain');
} catch (\InvalidArgumentException $e) {
Copy link
Member

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.

Copy link
Author

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

Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

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

done @xabbuh

@wouterj
Copy link
Member

wouterj commented Feb 16, 2015

5000 PR 🎉

return;
}

$definition = $container->getDefinition(
$definition = $container->get(
Copy link
Member

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
@wouterj
Copy link
Member

wouterj commented Feb 19, 2015

👍

@xavismeh
Copy link
Author

🎉

@weaverryan
Copy link
Member

Wow, this is really subtle! Very nice catch @xavismeh! Ok, we're half way to 10,000. Let's get to work! ;)

@weaverryan weaverryan merged commit c9caef6 into symfony:2.3 Mar 2, 2015
weaverryan added a commit that referenced this pull request Mar 2, 2015
…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
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.

4 participants