Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Default hidden question to 1 attempt for non-tty session#36590

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromostrolucky:fix-infinite-hidden-loop
May 4, 2020

Conversation

@ostrolucky
Copy link
Contributor

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#36565
LicenseMIT
Doc PR

Problem 1

validateAttempts() method repeats validation forever by default, until exception extendingRuntimeException isn't thrown. This currently happens disregarding if user is in tty session where they can actually type input, or non-tty session. This presents a problem when user code throws custom exceptions for hidden questions -> loop doesn't stop. As far as I can tell this issue is in all Symfony versions, but it was uncovered only after we stopped marking interactive flag to false automatically ourselves. Actually, all 3 problems were already existing problems, just hidden until now.

Problem 2

Infinite loop problem is related to hidden questions, but this one isn't. If validation fails, another attempt to read & validate happens. This means user will get two prompts: 2x same question with 2 different error messages. One error message coming from validator, second error message about inability to read input (because this loop repeats until this kind of error happens, so last output will always be this error). As an example, output in practice would look like following

 What do you want to do: >                                                                                  [ERROR] Action must not be empty.                                                                                                                               What do you want to do: >               Aborted.

So even if loop stops, output is more than expected.

Problem 3

This is purely cosmetic issue, but currently user getsstty: stdin isn't a terminal printed additionally when question helper tries to ask a hidden question without having tty. I have fixed this in same fashion as was already done forgetShell() method.

More details

Well root of the first problem is that\Symfony\Component\Console\Helper\QuestionHelper::getHiddenResponse is inconsistent. In some cases it does throwMissingInputException (which extendsRuntimeException), in others doesn't. This is because in others,shell_exec is used, which won't returnfalse even in non-tty sessions. Initially I attempted to fix this and make them consistent by checking for empty result +isTty call, but during my testing I found that at least last,bash -c method returns\n as output both when passing empty input and when passing newline as input. This means we cannot differentiate with this technique when input is really empty, or at least I can't currently tell how, maybe someone does. I had also idea to use proc_open and check ifSTDERR cotains message about stdin not being a terminal, but I realized these functions might not be available. In future we should modernize this method to use less hacky techniques. Other solutions, eg. Inquirer.js orhoa/console have much more elegant solutions. Anyway, since I encountered this issue and additionally this doesn't solve Problem 2, I stopped trying to fix this on this level.

Alternative solution

Alternative solution to problem 1 and 3 would be to fallback to default in case of hidden questions when tty is missing. But this still doesn't solve problem 2 and I can't think about solution right now which would fix problem 2 separately. We also didn't really reach consensus if reading passwords via stdin is desired. I tried this inInquirer.js and this librarydoes read password from stdin

@chalasrchalasr added this to the4.4 milestoneApr 27, 2020
@fabpot
Copy link
Member

Thank you@ostrolucky.

@fabpotfabpot merged commit64e5a9d intosymfony:4.4May 4, 2020
This was referencedMay 31, 2020
nicolas-grekas added a commit that referenced this pull requestJul 3, 2020
…tions (nicolas-grekas)This PR was merged into the 4.4 branch.Discussion----------[Console] always use stty when possible to ask hidden questions| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#36565, replaces#36590| License       | MIT| Doc PR        | -The current code doesn't make much sense: we check `hasSttyAvailable()`, and if the answer is `false`, we still use `stty` directly.This PR relies on `stream_isatty` and equivalent fallback checks to decide if the password can be hidden or not.Best reviewed [ignoring whitespaces](https://github.com/symfony/symfony/pull/37469/files?w=1).Commits-------055b605 [Console] always use stty when possible to ask hidden questions
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@helhumhelhumhelhum approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

6 participants

@ostrolucky@fabpot@nicolas-grekas@helhum@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp