-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Fix infinite loop on missing input #20377
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
[Console] Fix infinite loop on missing input #20377
Conversation
public function testAskThrowsExceptionOnMissingInputWithValidator() | ||
{ | ||
$dialog = new QuestionHelper(); | ||
$dialog->setInputStream($this->getInputStream('')); |
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.
Be careful when merging, this method has been deprecated so we need to remove this line and change $this->createInputInterfaceMock()
by $this->createStreamableInputInterfaceMock($this->getInputStream(''))
below. Same for the test added in SymfonyQuestionHelperTest
.
Could be combined with #20376, would ease review, and code is related. |
9405bd5
to
cb0a58b
Compare
@nicolas-grekas Indeed, done. |
👍 |
@@ -136,7 +136,7 @@ public function doAsk(OutputInterface $output, Question $question) | |||
if (false === $ret) { | |||
$ret = fgets($inputStream, 4096); | |||
if (false === $ret) { | |||
throw new \RuntimeException('Aborted'); | |||
throw new RuntimeException('Aborted'); |
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.
I know that this exception class does not exist in 2.7, but the bug is there as well, right?
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.
Yes, it is. Would you catch any \RuntimeException
in 2.7?
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.
I think it would make sense
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.
Isn't it doable to backport this exception class in 2.7?
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.
Indeed, I think that would be best.
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.
Not sure it is the right way to proceed but I added a simple extension of \RuntimeException
which is used where it's needed, and rebased this.
cb0a58b
to
9a8943e
Compare
9a8943e
to
263fad5
Compare
263fad5
to
04ccc84
Compare
[Console] Use console exception for missing input Backport Console RuntimeException in 2.7
04ccc84
to
e64de1e
Compare
Thank you @chalasr. |
This PR was merged into the 2.7 branch. Discussion ---------- [Console] Fix infinite loop on missing input | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20277 | License | MIT | Doc PR | n/a This fixes the infinite loop occurring when no input is provided for a question which has a validator and no max attempts (`null`), e.g. when using `SymfonyStyle::ask()` which automatically adds a validator. Commits ------- e64de1e [Console] Fix infinite loop on missing input
This fixes the infinite loop occurring when no input is provided for a question which has a validator and no max attempts (
null
), e.g. when usingSymfonyStyle::ask()
which automatically adds a validator.