minor #24395 [Process] Removed dead code in the start method (lyrixx)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[Process] Removed dead code in the start method

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

1eee2a461c [Process] Removed dead code in the start method
This commit is contained in:
Fabien Potencier 2017-10-05 05:40:59 -07:00
commit 7c74f09adf
1 changed files with 9 additions and 18 deletions

View File

@ -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;