-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] invalid default returned from ChoiceQuestion on non interactive mode #30774
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
Comments
When you follow the symfony docs to create a
it will display the same output for See https://symfony.com/doc/current/components/console/helpers/questionhelper.html#let-the-user-choose-from-a-list-of-answers for more information and try to update your code to:
|
The inconsistent result happens when using string keys for choices, the |
Thanks 👍 |
…non-interactive mode (chalasr) This PR was merged into the 3.4 branch. Discussion ---------- [Console] Fix inconsistent result for choice questions in non-interactive mode | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? |no | BC breaks? | no | Deprecations? | n/a | Tests pass? | yes | Fixed tickets | #30774 | License | MIT | Doc PR | n/a Commits ------- 198b895 [Console] Fix inconsistent result for choice questions in non-interactive mode
Symfony version(s) affected: symfony/console v4.2.3
Description
ChoiceQuestion returns the index in interactive mode but the value in non interactive mode
How to reproduce
Using this command:
Then
php bin/console test
orphp bin/console -n
will not display the same value.Possible Solution
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Helper/QuestionHelper.php#L56 should probably return default, and not the value.
Additional context
The opposite bug with reported in #25470 , the non-interactive mode was returning the index instead of the value. I suppose the return value was changed from value to index meanwhile?
The text was updated successfully, but these errors were encountered: