-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] don't check tty on stdin, it breaks with "data lost during stream conversion" #36696
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
Conversation
What's the reproduction scenario for this? There is an phpt integration test using stdin and question helper, I'm wondering why it didn't fail. Code I used is inspired by former code in Application class and there was no |
|
Thank you @nicolas-grekas. |
@@ -477,6 +473,8 @@ private function validateAttempts(callable $interviewer, OutputInterface $output | |||
throw $e; | |||
} catch (\Exception $error) { | |||
} | |||
|
|||
$attempts = $attempts ?? -(int) $this->isTty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the motivation to move this inside a loop because isTty() result may change between iterations? I wonder how can that happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "$several_answers" | the-command
breaks in real life, with stream_isatty()
emitting PHP warnings "data lost during stream conversion"
.
Moving after reading the response means we never hit this line when correct responses are provided. Which is the case in the described situation (programmatic filling of answers.)
/cc @ostrolucky FYI