-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] BUG: revert negatable ansi #41723
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
When I create a command and configure it with the addOption 'no-ansi', the current 5.3 is throwing an exception. The reason behind it is, that it is configure as negatable. When it is adding it check if the no-ansi is exists. Then it throws an exception. In the 5.2 situation it then checked if the options equals. If not throw an exception. https://github.com/symfony/console/blob/5.3/Input/InputDefinition.php#L255 part where the check is coming for the negatable and throws an exception. https://github.com/symfony/console/blob/5.3/Input/InputDefinition.php#L233 The equals check where in the past the error was prevented. Reverting the option to two values, seems like the right solution.
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
I understand your issue but I think this is not the best solution to revert changes to the |
I'd also prefer to not revert the change.
edit: I was wrong here, |
@YaFou I had also checked to add the check (https://github.com/symfony/console/blob/5.3/Input/InputDefinition.php#L233), beacuse I add an option with the name no-ansi it is comparing with the name ansi and then the check will return false, That is not working, Reproduce the bug. Create a command class, in the configure method set |
Well, creating the same option in a command and in the application is something we should forbid, as things will break in subtle ways if the 2 places don't apply the same config on the option. |
@stof true point, that is why I would propose a revert, becasue then I can add someting twice with the same settings. which aint possible for a negetable |
I agree with the revert in 5.3, but I think 5.4 should deprecated overriding application-level options (and 6.0 should forbid it), to avoid such subtle breakages. |
Why not deprecate it now @stof? Maybe because it is on a maintenance branch? |
yes. Deprecations cannot be introduced in patch releases |
If we do this, I'd also like to switch back to negatable on 6.0. |
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.
The tests need some love after your change.
Before merging this PR in 5.3, could you please open a PR in 5.4 that deprecate overriding an option, and allow us to revert this PR in 6.0? |
👍 for merging this. This issue is causing a lot of issues for Laravel users, which make up a large number of monthly downloads of this component. |
Better to break code that's only been here for a few weeks, than to break code that's been here for years. |
Hmm.. I dug into the issue and started working on a fix (#41792), but I realized that this does not make sense.
Both previous points leads to: in symfony < 5.3, adding an option
Do you have such issue @GrahamCampbell ? because laravel/tinker#127 is not related. This issue should be addressed by #41794 |
When I create a command and configure it with the addOption 'no-ansi', the current 5.3 is throwing an exception.
The reason behind it is, that it is configure as negatable. When it is adding it check if the no-ansi is exists. Then it throws an exception.
In the 5.2 situation it then checked if the options equals. If not throw an exception.
https://github.com/symfony/console/blob/5.3/Input/InputDefinition.php#L255 part where the check is coming for the negatable and throws an exception.
https://github.com/symfony/console/blob/5.3/Input/InputDefinition.php#L233 The equals check where in the past the error was prevented.
Reverting the option to two values, seems like the right solution.