8000 Merge branch '3.2' · romainneutron/symfony@d0e904b · GitHub
[go: up one dir, main page]

Skip to content

Commit d0e904b

Browse files
committed
Merge branch '3.2'
* 3.2: [Process] Fix bug which wiped or mangled env vars
2 parents 195e464 + da7893a commit d0e904b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function start(callable $callback = null/*, array $env = array()*/)
303303
$envBackup = array();
304304
if (null !== $env && $inheritEnv) {
305305
foreach ($env as $k => $v) {
306-
$envBackup[$k] = getenv($v);
306+
$envBackup[$k] = getenv($k);
307307
putenv(false === $v || null === $v ? $k : "$k=$v");
308308
}
309309
$env = null;

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,20 @@ public function testSetBadEnv()
13971397
$this->assertSame('', $process->getErrorOutput());
13981398
}
13991399

1400+
public function testEnvBackupDoesNotDeleteExistingVars()
1401+
{
1402+
putenv('existing_var=foo');
1403+
$process = $this->getProcess('php -r "echo getenv(\'new_test_var\');"');
1404+
$process->setEnv(array('existing_var' => 'bar', 'new_test_var' => 'foo'));
1405+
$process->inheritEnvironmentVariables();
1406+
1407+
$process->run();
1408+
1409+
$this->assertSame('foo', $process->getOutput());
1410+
$this->assertSame('foo', getenv('existing_var'));
1411+
$this->assertFalse(getenv('new_test_var'));
1412+
}
1413+
14001414
public function testEnvIsInherited()
14011415
{
14021416
$process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ'));

0 commit comments

Comments
 (0)
0