Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] block input stream if needed #50429

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
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Console] block input stream if needed
When the input stream used in the question helper is not blocking, the default value is always used as the stream return false.
In order to fix that, we force the stream to be in blocking state and go back to the old state after so other logic is not impacted
by this change
  • Loading branch information
joelwurtz committed May 25, 2023
commit 8ae36f3cdc57cce28c9cbef4e0541830cc79a2dc
11 changes: 11 additions & 0 deletions 11 src/Symfony/Component/Console/Helper/QuestionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,18 @@ private function doAsk(OutputInterface $output, Question $question)
}

if (false === $ret) {
$isBlocked = stream_get_meta_data($inputStream)['blocked'] ?? true;

if (!$isBlocked) {
stream_set_blocking($inputStream, true);
}

$ret = $this->readInput($inputStream, $question);

if (!$isBlocked) {
stream_set_blocking($inputStream, false);
}

if (false === $ret) {
throw new MissingInputException('Aborted.');
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.