JakubOnderka / PHP-Parallel-Lint

This tool check syntax of PHP files faster than serial check with fancier output.
Other
647 stars 62 forks source link

proc_open returns NULL #68

Closed simonsunx closed 8 years ago

simonsunx commented 8 years ago

Hello.

This is line 47 in https://github.com/JakubOnderka/PHP-Parallel-Lint/blob/master/src/Process/Process.php:

$this->process = proc_open($cmdLine, $descriptors, $pipes, null, null, array('bypass_shell' => true));

It was modified:

    echo 'cmd=';var_dump($cmdLine);echo PHP_EOL;
    echo 'descriptors=';var_dump($descriptors);echo PHP_EOL;
    echo 'pipes=';var_dump($pipes);echo PHP_EOL;
    $this->process = proc_open($cmdLine, $descriptors, $pipes, null, null, array('bypass_shell' => true));
    echo 'is_resource=';var_dump(is_resource($this->process));echo PHP_EOL;
    echo 'process=';var_dump($this->process);echo PHP_EOL;

And execution returned: ------8<------ $ ./vendor/bin/parallel-lint local/ cmd=string(112) "'php' -n -r 'echo '\''PHP;'\'', PHP_VERSION_ID, '\'';'\'', defined('\''HPHP_VERSION'\'') ? HPHP_VERSION : null;'"

descriptors=array(3) { [0] => array(2) { [0] => string(4) "pipe" [1] => string(1) "r" } [1] => array(2) { [0] => string(4) "pipe" [1] => string(1) "w" } [2] => array(2) { [0] => string(4) "pipe" [1] => string(1) "w" } }

pipes=NULL

is_resource=bool(false)

process=NULL

cmd=string(115) "'php' --php -r 'echo '\''PHP;'\'', PHP_VERSION_ID, '\'';'\'', defined('\''HPHP_VERSION'\'') ? HPHP_VERSION : null;'"

descriptors=array(3) { [0] => array(2) { [0] => string(4) "pipe" [1] => string(1) "r" } [1] => array(2) { [0] => string(4) "pipe" [1] => string(1) "w" } [2] => array(2) { [0] => string(4) "pipe" [1] => string(1) "w" } }

pipes=NULL

is_resource=bool(false)

process=NULL

'php' is not valid PHP binary. ------8<------

Maybe condition «$this->process === false» needs «or» statement:

$this->process === false || !is_resource($this->process)

JakubOnderka commented 8 years ago

Thanks for error report! Probably it is an error in PHP. Can you please send me operation system and PHP version?

simonsunx commented 8 years ago

Hello, J.

Thanks to you for your linter.

Let's see: $ uname -a Linux template.rcloud 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux $ php -v PHP 5.5.20 (cli) (built: Dec 17 2014 15:09:12) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.6, Copyright (c) 2002-2014, by Derick Rethans

I think reason is discovered in this php.ini setting: disable_functions =exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source

I tried to launch linter by command:

$ ./vendor/bin/parallel-lint -p 'php -d disable_functions=""' local/

but result was the same:

'php -d disable_functions=""' is not valid PHP binary.

Some moments ago I tryed to execute

php -d disable_functions="" -f vendor/jakub-onderka/php-parallel-lint/parallel-lint.php local/

and launch was successful.

I hope my experience will be helpful.

JakubOnderka commented 8 years ago

If is proc_open disabled, an error message is shown, but I also add a check for proc_open return code.

Thank you very much for great error report :)