Merge branch '3.2'

* 3.2:
  [Process] Fix ignoring of bad env var names
This commit is contained in:
Nicolas Grekas 2017-02-27 23:48:55 +01:00
commit 68e1cb81f2
2 changed files with 17 additions and 0 deletions

View File

@ -1137,6 +1137,11 @@ class Process implements \IteratorAggregate
*/
public function setEnv(array $env)
{
// Process can not handle env values that are arrays
$env = array_filter($env, function ($value) {
return !is_array($value);
});
$this->env = $env;
return $this;

View File

@ -1385,6 +1385,18 @@ class ProcessTest extends TestCase
$this->assertSame('456', $p2->getOutput());
}
public function testSetBadEnv()
{
$process = $this->getProcess('echo hello');
$process->setEnv(array('bad%%' => '123'));
$process->inheritEnvironmentVariables(true);
$process->run();
$this->assertSame('hello'.PHP_EOL, $process->getOutput());
$this->assertSame('', $process->getErrorOutput());
}
public function testEnvIsInherited()
{
$process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ'));