-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Don't create unused alias if the command is public #22410
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
Conversation
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.
👍
Merging into 3.3 as this is not a bug fix. |
Can you rebase on master? That would help me. Thanks. |
56d9eb2
to
32d6476
Compare
32d6476
to
cd4a01c
Compare
Rebased on master. |
$alias2 = $alias1.'_my-command2'; | ||
$this->assertTrue($container->hasAlias($alias1)); | ||
$this->assertTrue($container->hasAlias($alias2)); | ||
} |
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.
This test has been added to the legacy test case by mistake, copied it there.
Thank you @chalasr. |
…nd is public (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Don't create unused alias if the command is public | Q | A | ------------- | --- | Branch? | maste | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Currently, a public alias is created for any `console.command` tagged service, but this alias is unused if the service is public (as it would be useless). Commits ------- cd4a01c Don't create unused aliases for public command
Actually, it was used here so this should be reverted in big part (we can only remove |
I'll take care of this. |
@GuilhemN In fact public command services are still properly registered. What happens:
So the behavior is not broken, but causes an unnecessary reflection class instantiation when it is possible (which should rarely be the case but still) followed by some method calls. |
Ok, thanks for investigating deeper than I did, it works as is but the line I mentionned is meant to prevent the reflection call so having your fix would be great indeed ☺ |
See #22579 |
…for command public services (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [Console][HttpKernel] Avoid reflection-based registration for command public services | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22410 (comment) | License | MIT | Doc PR | n/a By mapping commands ids by their alias in `console.command.ids` (even if the alias is not registered in the container for public services), then skipping reflection if the predictable alias exists as a key of `console.command.ids`. Please note that the whole command service registration process is far from ideal. I'm working on changing this for 3.4 in a transparent way regarding end users, leveraging PSR-11 to make the console component DI friendly, allowing to register commands as true private services (no more public aliases) and providing laziness for those. Commits ------- 6c1b384 Avoid reflection-based registration for command public services
Currently, a public alias is created for any
console.command
tagged service, but this alias is unused if the service is public (as it would be useless).