8000 bug #22183 [Process] Fix bug which wiped or mangled env vars (pjcdawk… · romainneutron/symfony@da7893a · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit da7893a

Browse files
committed
bug symfony#22183 [Process] Fix bug which wiped or mangled env vars (pjcdawkins)
This PR was squashed before being merged into the 3.2 branch (closes symfony#22183). Discussion ---------- [Process] Fix bug which wiped or mangled env vars | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A Fixing (and testing) a one-character bug introduced in a recent commit symfony/process@7d21c4a Commits ------- 9439237 [Process] Fix bug which wiped or mangled env vars
2 parents 56d4769 + 9439237 commit da7893a

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
@@ -277,7 +277,7 @@ public function start(callable $callback = null)
277277
}
278278

279279
foreach ($env as $k => $v) {
280-
$envBackup[$k] = getenv($v);
280+
$envBackup[$k] = getenv($k);
281281
putenv(false === $v || null === $v ? $k : "$k=$v");
282282
}
283283
$env = null;

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

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

1406+
public function testEnvBackupDoesNotDeleteExistingVars()
1407+
{
1408+
putenv('existing_var=foo');
1409+
$process = $this->getProcess('php -r "echo getenv(\'new_test_var\');"');
1410+
$process->setEnv(array('existing_var' => 'bar', 'new_test_var' => 'foo'));
1411+
$process->inheritEnvironmentVariables();
1412+
1413+
$process->run();
1414+
1415+
$this->assertSame('foo', $process->getOutput());
1416+
$this->assertSame('foo', getenv('existing_var'));
1417+
$this->assertFalse(getenv('new_test_var'));
1418+
}
1419+
14061420
public function testInheritEnvEnabled()
14071421
{
14081422
$process = $this->getProcess(self::$phpBin.' -r '.escapeshellarg('echo serialize($_SERVER);'), null, array('BAR' => 'BAZ'));

0 commit comments

Comments
 (0)
0