diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 6141c8b475..5e1e369cff 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -268,26 +268,21 @@ class Process implements \IteratorAggregate } } - if (null === $env) { - $env = $this->env; - } elseif ($this->env) { + if ($this->env) { $env += $this->env; } $envBackup = array(); - if (null !== $env) { - foreach ($env as $k => $v) { - $envBackup[$k] = getenv($k); - putenv(false === $v || null === $v ? $k : "$k=$v"); - } - $env = null; + foreach ($env as $k => $v) { + $envBackup[$k] = getenv($k); + putenv(false === $v || null === $v ? $k : "$k=$v"); } $options = array('suppress_errors' => true); if ('\\' === DIRECTORY_SEPARATOR) { $options['bypass_shell'] = true; - $commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env); + $commandline = $this->prepareWindowsCommandLine($commandline, $envBackup); } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) { // last exit code is output on the fourth pipe and caught to work around --enable-sigchild $descriptors[3] = array('pipe', 'w'); @@ -301,7 +296,7 @@ class Process implements \IteratorAggregate $ptsWorkaround = fopen(__FILE__, 'r'); } - $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $options); + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, null, $options); foreach ($envBackup as $k => $v) { putenv(false === $v ? $k : "$k=$v"); @@ -1464,7 +1459,7 @@ class Process implements \IteratorAggregate return true; } - private function prepareWindowsCommandLine($cmd, array &$envBackup, array &$env = null) + private function prepareWindowsCommandLine($cmd, array &$envBackup) { $uid = uniqid('', true); $varCount = 0; @@ -1477,7 +1472,7 @@ class Process implements \IteratorAggregate [^"%!^]*+ )++ ) | [^"]*+ )"/x', - function ($m) use (&$envBackup, &$env, &$varCache, &$varCount, $uid) { + function ($m) use (&$envBackup, &$varCache, &$varCount, $uid) { if (!isset($m[1])) { return $m[0]; } @@ -1495,11 +1490,7 @@ class Process implements \IteratorAggregate $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"'; $var = $uid.++$varCount; - if (null === $env) { - putenv("$var=$value"); - } else { - $env[$var] = $value; - } + putenv("$var=$value"); $envBackup[$var] = false;