From 6d089ac437615732322609af677dba56e414be29 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 5 May 2020 11:01:49 +0200 Subject: [PATCH] [Console] fix "data lost during stream conversion" with QuestionHelper --- src/Symfony/Component/Console/Helper/QuestionHelper.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 4e0afeae78a0..92f9ddcff355 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -462,10 +462,6 @@ private function validateAttempts(callable $interviewer, OutputInterface $output $error = null; $attempts = $question->getMaxAttempts(); - if (null === $attempts && !$this->isTty()) { - $attempts = 1; - } - while (null === $attempts || $attempts--) { if (null !== $error) { $this->writeError($output, $error); @@ -477,6 +473,8 @@ private function validateAttempts(callable $interviewer, OutputInterface $output throw $e; } catch (\Exception $error) { } + + $attempts = $attempts ?? -(int) $this->isTty(); } throw $error; @@ -517,7 +515,7 @@ private function isTty(): bool return stream_isatty($inputStream); } - if (!\function_exists('posix_isatty')) { + if (\function_exists('posix_isatty')) { return posix_isatty($inputStream); }