Skip to content

Commit 6d089ac

Browse files
[Console] fix "data lost during stream conversion" with QuestionHelper
1 parent 2732dda commit 6d089ac

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,6 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
462462
$error = null;
463463
$attempts = $question->getMaxAttempts();
464464

465-
if (null === $attempts && !$this->isTty()) {
466-
$attempts = 1;
467-
}
468-
469465
while (null === $attempts || $attempts--) {
470466
if (null !== $error) {
471467
$this->writeError($output, $error);
@@ -477,6 +473,8 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
477473
throw $e;
478474
} catch (\Exception $error) {
479475
}
476+
477+
$attempts = $attempts ?? -(int) $this->isTty();
480478
}
481479

482480
throw $error;
@@ -517,7 +515,7 @@ private function isTty(): bool
517515
return stream_isatty($inputStream);
518516
}
519517

520-
if (!\function_exists('posix_isatty')) {
518+
if (\function_exists('posix_isatty')) {
521519
return posix_isatty($inputStream);
522520
}
523521

0 commit comments

Comments
 (0)