[ticket/10716] Collect standard error from executed php process.

php executes everything via a shell. The standard error of this
top level shell is not captured by exec/shell_exec/popen/etc.
and there is no way to capture it. proc_open might work but it
is a nightmare to use and without multiplexing reads from
standard error and standard output it can deadlock.

Thus the solution in this commit. Put the command into a subshell
and redirect standard error to standard output for the subshell.

PHPBB3-10716
This commit is contained in:
Oleg Pudeyev 2012-12-04 18:52:27 -05:00
parent 8ea52b5619
commit fb261e19ff

View file

@ -15,9 +15,10 @@ class phpbb_lint_test extends phpbb_test_case
{ {
$output = array(); $output = array();
$status = 1; $status = 1;
exec('php -v', $output, $status); exec('(php -v) 2>&1', $output, $status);
if ($status) if ($status)
{ {
$output = implode("\n", $output);
self::markTestSkipped("php is not in PATH or broken: $output"); self::markTestSkipped("php is not in PATH or broken: $output");
} }
@ -61,7 +62,7 @@ class phpbb_lint_test extends phpbb_test_case
else if (substr($filename, strlen($filename)-4) == '.php') else if (substr($filename, strlen($filename)-4) == '.php')
{ {
// assume php binary is called php and it is in PATH // assume php binary is called php and it is in PATH
$cmd = 'php -l ' . escapeshellarg($path); $cmd = '(php -l ' . escapeshellarg($path) . ') 2>&1';
$output = array(); $output = array();
$status = 1; $status = 1;
exec($cmd, $output, $status); exec($cmd, $output, $status);