diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 4bebbb4d9a..d7c5a61b16 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -326,8 +326,16 @@ class Process implements \IteratorAggregate // @see : https://bugs.php.net/69442 $ptsWorkaround = fopen(__FILE__, 'r'); } + if (defined('HHVM_VERSION')) { + $envPairs = $env; + } else { + $envPairs = array(); + foreach ($env as $k => $v) { + $envPairs[] = $k.'='.$v; + } + } - $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $this->options); + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); if (!is_resource($this->process)) { throw new RuntimeException('Unable to launch a new process.'); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index c927da6471..16e57d3763 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1423,14 +1423,14 @@ class ProcessTest extends TestCase public function testEnvIsInherited() { - $process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ')); + $process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ', 'EMPTY' => '')); putenv('FOO=BAR'); $_ENV['FOO'] = 'BAR'; $process->run(); - $expected = array('BAR' => 'BAZ', 'FOO' => 'BAR'); + $expected = array('BAR' => 'BAZ', 'EMPTY' => '', 'FOO' => 'BAR'); $env = array_intersect_key(unserialize($process->getOutput()), $expected); $this->assertEquals($expected, $env); @@ -1511,7 +1511,7 @@ Array ) EOTXT; - $this->assertSame($expected, $p->getOutput()); + $this->assertSame($expected, str_replace('Standard input code', '-', $p->getOutput())); } public function provideEscapeArgument()