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

Appearance settings

[Console] HHVM read input stream bug #17253

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

Closed
wants to merge 3 commits into from

Conversation

mbutkereit
Copy link

Q A
Bug fix? [yes]
New feature? [no]
BC breaks? [no]
Deprecations? [no]
Tests pass? [yes]
License MIT

HHVM readline() function requires a parameter see:

https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/readline/ext_readline.php

But the php readline does not require one.

In   Symfony\Component\Console\Helper\QuestionHelper
 …
 readFromInput($stream)
 …

we use readline() without a parameter.

HHVM Version:

HipHop VM 3.10.1 (rel)
Compiler: tags/HHVM-3.10.1-0-g689b4969a141620ee5a282ce0dbf72278c84d44b
Repo schema: 6c99ee1f98340f6f3ef397a332583f0e843a627d

Docker Container:

docker run --rm -it -v `pwd`:`pwd` -w `pwd` brunoric/hhvm:deb hhvm test.php ls 

Test.php

<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

use Symfony\Component\Console\Helper\QuestionHelper;

require_once  "vendor/autoload.php";

$console = new Application();

$console
    ->register('ls')
    ->setDescription('Try input')
    ->setCode(function (InputInterface $input, OutputInterface $output) {

        $question = new Question('Your email address: ');
        $question->setValidator(
            function ($answer) {
                return $answer;
            }
        );
        $question->setMaxAttempts(5);
            $helper = new QuestionHelper();
          $email = $helper->ask($input, $output, $question);

        $output->writeln(sprintf('Email Adress: <info>%s</info>', $email));
    })
;
$console->run();

composer.json

{
    "require": {
        "symfony/console": "^3.0"
    }
}

Result:
No input is possible and you got a warning

Your email address: 
Warning: readline() expects exactly 1 parameter, 0 given in /clitest/vendor/symfony/console/Helper/QuestionHelper.php on line 436
Email Adress:

Fix:
Add a empty string parameter to readline() or use fgets() for hhvm.

@xabbuh
Copy link
Member

xabbuh commented Jan 4, 2016

Can you add a test to avoid regressions?

@@ -437,7 +437,7 @@ private function getShell()
*/
private function readFromInput($stream)
{
if (STDIN === $stream && function_exists('readline')) {
if (STDIN === $stream && function_exists('readline') && !defined('HHVM_VERSION')) {
$ret = readline();
Copy link
Member

Choose a reason for hiding this comment

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

giving the empty string looks more feature-full, isn't it? why prefer fgets on hhvm when readline works?

@mbutkereit
Copy link
Author

@nicolas-grekas i think you are right. (i have changed it)
@xabbuh i dont' know how i can write a test for readline().
Does it make sense to test stdin( readline() ) ? i don't know.

@stof
Copy link
Member

stof commented Jan 8, 2016

Please also report it to HHVM as an incompatibility bug.

@mbutkereit
Copy link
Author

@stof done see facebook/hhvm#6731

@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@nicolas-grekas
Copy link
Member

Thank you @mbutkereit.

nicolas-grekas added a commit that referenced this pull request Jan 14, 2016
This PR was squashed before being merged into the 2.8 branch (closes #17253).

Discussion
----------

[Console] HHVM read input stream bug

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| License       | MIT

HHVM readline() function requires a parameter  see:

https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/readline/ext_readline.php

But the php readline does not require one.
```
In   Symfony\Component\Console\Helper\QuestionHelper
 …
 readFromInput($stream)
 …
```
we use readline() without a parameter.

HHVM Version:
```
HipHop VM 3.10.1 (rel)
Compiler: tags/HHVM-3.10.1-0-g689b4969a141620ee5a282ce0dbf72278c84d44b
Repo schema: 6c99ee1f98340f6f3ef397a332583f0e843a627d
```

Docker Container:
```
docker run --rm -it -v `pwd`:`pwd` -w `pwd` brunoric/hhvm:deb hhvm test.php ls
```
Test.php
```
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

use Symfony\Component\Console\Helper\QuestionHelper;

require_once  "vendor/autoload.php";

$console = new Application();

$console
    ->register('ls')
    ->setDescription('Try input')
    ->setCode(function (InputInterface $input, OutputInterface $output) {

        $question = new Question('Your email address: ');
        $question->setValidator(
            function ($answer) {
                return $answer;
            }
        );
        $question->setMaxAttempts(5);
		    $helper = new QuestionHelper();
	      $email = $helper->ask($input, $output, $question);

        $output->writeln(sprintf('Email Adress: <info>%s</info>', $email));
    })
;
$console->run();
```

composer.json
```
{
    "require": {
        "symfony/console": "^3.0"
    }
}
```

Result:
No input is possible and you got a warning
```
Your email address:
Warning: readline() expects exactly 1 parameter, 0 given in /clitest/vendor/symfony/console/Helper/QuestionHelper.php on line 436
Email Adress:
```

Fix:
Add a empty string parameter to  readline() or use fgets() for hhvm.

Commits
-------

e7f17a7 [Console] HHVM read input stream bug
@fabpot fabpot mentioned this pull request Jan 14, 2016
@fabpot fabpot mentioned this pull request Feb 3, 2016
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.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.