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

Skip to content

[Console] fix backwards-compatibility with overridden add() methods #60796

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
Jun 16, 2025

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jun 15, 2025

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

The current (wrong) behaviour can be observed in the high deps job on the 7.3 branch: https://github.com/symfony/symfony/actions/runs/15662516138/job/44122290781#step:9:9940

The reason for the failure is that the Application class in init() no longer calls add() which is overridden in the extending Application class from FrameworkBundle doing the container-based command registration.

@xabbuh xabbuh requested a review from chalasr as a code owner June 15, 2025 19:42
@carsonbot carsonbot added this to the 7.4 milestone Jun 15, 2025
@xabbuh xabbuh force-pushed the pr-60394 branch 2 times, most recently from 9a4a74b to 19b60d4 Compare June 15, 2025 20:04
$console->addCommand($application);

if (!method_exists($console, 'addCommand') || (new \ReflectionMethod($console, 'add'))->getDeclaringClass()->getName() !== (new \ReflectionMethod($console, 'addCommand'))->getDeclaringClass()->getName()) {
$adder = $console->add(...);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$adder = $console->add(...);
$console->add($application);

@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit 7b19f53 into symfony:7.4 Jun 16, 2025
10 of 11 checks passed
@xabbuh xabbuh deleted the pr-60394 branch June 16, 2025 09:38
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