Skip to content
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

[Console] Reset question validator attempts only for actual stdin (bis) #37286

Merged
merged 1 commit into from Jun 15, 2020

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

#37160 fails, this should fix it by looking at the actual input stream.

if (!\defined('STDIN')) {
$inputStream = $this->inputStream ?: fopen('php://stdin', 'r');

if ('php://stdin' !== (stream_get_meta_data($inputStream)['url'] ?? null)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this is not needed to fix the failure, but making the behavior of this method global looks suspicious to me so here is a local check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this check works even if $inputStream === STDIN

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure with url here?

>>> stream_get_meta_data(STDIN)['url']
PHP Notice:  Undefined index: url in phar://eval()'d code on line 1
=> null
>>> stream_get_meta_data(STDIN)
=> [
     "timed_out" => false,
     "blocked" => true,
     "eof" => false,
     "wrapper_type" => "PHP",
     "stream_type" => "STDIO",
     "mode" => "rb",
     "unread_bytes" => 0,
     "seekable" => false,
     "uri" => "php://stdin",
   ]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much yes: https://3v4l.org/njZZV
What's your runtime?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That 3v4l snippet follows behaviour I observe on my PC, it looks to be uri, not url

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

return true;
}

if (\function_exists('stream_isatty')) {
return stream_isatty(fopen('php://input', 'r'));
return stream_isatty($inputStream);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was my mistake: using php://stdin here instead is enough to fix the failure

@nicolas-grekas nicolas-grekas merged commit 943c630 into symfony:4.4 Jun 15, 2020
@nicolas-grekas nicolas-grekas deleted the console-stdin branch June 18, 2020 17:54
weaverryan added a commit to symfony/maker-bundle that referenced this pull request Jul 6, 2020
… (weaverryan)

This PR was squashed before being merged into the 1.0-dev branch.

Discussion
----------

using stable-dev in tests to get latest fixes from Symfony

This avoids a behavior change in symfony/console@6f533d9...d2c9f77 from symfony/symfony#37286

I'll create a PR to revert this after merge, which we will merge once the issue is resolved.

Commits
-------

1309c01 updating test in one other spot
ccfd248 forcing stable ORM in tests
6b512b8 making migration test work in all versions
b5a5a11 phpcs
6af124a Guaranteeing that dev versions will get dev dependencies
fd89d5d Forcing "stable" for 7.1
73f9ecc updating test for new version of migrations
0334718 Using stable-dev as default version in tests
This was referenced Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants