8000 ProcessBuilder clean up by Seldaek · Pull Request #3381 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

ProcessBuilder clean up #3381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 5, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restore bypass_shell by default with windows compat
  • Loading branch information
Seldaek committed Feb 22, 2012
commit 54cfd4410cbee463b532eb7b40c9d539ce233c70
5 changes: 4 additions & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
}
$this->stdin = $stdin;
$this->timeout = $timeout;
$this->options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false), $options);
$this->options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true), $options);
Copy link
Contributor
10000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change to array_replace().

}

/**
Expand Down Expand Up @@ -164,6 +164,9 @@ public function run($callback = null)

if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->enhanceWindowsCompatibility) {
$commandline = 'cmd /V:ON /E:ON /C "'.$commandline.'"';
if (!isset($this->options['bypass_shell'])) {
$this->options['bypass_shell'] = true;
}
}

$process = proc_open($commandline, $descriptors, $pipes, $this->cwd, $this->env, $this->options);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Process/ProcessBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(array $arguments = array())

$this->timeout = 60;
$this->options = array();
$this->inheritEnv = false;
$this->inheritEnv = true;
}

public static function create(array $arguments = array())
Expand Down Expand Up @@ -112,7 +112,7 @@ public function getProcess()

$env = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary.

if ($this->inheritEnv) {
$env = $_ENV ? $this->env + $_ENV : $this->env;
$env = $this->env ? $this->env + $_ENV : null;
} else {
$env = $this->env;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Symfony/Tests/Component/Process/ProcessBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function shouldInheritEnvironmentVars()
$pb->add('foo')->inheritEnvironmentVariables();
$proc = $pb->getProcess();

$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
$this->assertEquals(null, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');

$_ENV = $snapshot;
}
Expand All @@ -54,12 +54,12 @@ public function shouldInheritAndOverrideEnvironmentVars()
/**
* @test
*/
public function shouldNotInheritEnvironmentVarsByDefault()
public function shouldInheritEnvironmentVarsByDefault()
{
$pb = new ProcessBuilder();
$proc = $pb->add('foo')->getProcess();

$this->assertEquals(array(), $proc->getEnv());
$this->assertEquals(null, $proc->getEnv());
}

/**
Expand Down
0