8000 bug #36696 [Console] don't check tty on stdin, it breaks with "data l… · symfony/symfony@cf6e499 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf6e499

Browse files
committed
bug #36696 [Console] don't check tty on stdin, it breaks with "data lost during stream conversion" (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Console] don't check tty on stdin, it breaks with "data lost during stream conversion" | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - /cc @ostrolucky FYI Commits ------- 6d089ac [Console] fix "data lost during stream conversion" with QuestionHelper
2 parents 2732dda + 6d089ac commit cf6e499

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)
0