Skip to content

Commit 47ec02a

Browse files
committed
[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
1 parent a349882 commit 47ec02a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Helper/QuestionHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,18 @@ private function doAsk(OutputInterface $output, Question $question)
128128
}
129129

130130
if (false === $ret) {
131+
$isBlocked = stream_get_meta_data($inputStream)['blocked'] ?? true;
132+
133+
if (!$isBlocked) {
134+
stream_set_blocking($inputStream, true);
135+
}
136+
131137
$ret = $this->readInput($inputStream, $question);
138+
139+
if (!$isBlocked) {
140+
stream_set_blocking($inputStream, false);
141+
}
142+
132143
if (false === $ret) {
133144
throw new MissingInputException('Aborted.');
134145
}

0 commit comments

Comments
 (0)