File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/Symfony/Component/Process Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ public function start(callable $callback = null)
277
277
}
278
278
279
279
foreach ($ env as $ k => $ v ) {
280
- $ envBackup [$ k ] = getenv ($ v );
280
+ $ envBackup [$ k ] = getenv ($ k );
281
281
putenv (false === $ v || null === $ v ? $ k : "$ k= $ v " );
282
282
}
283
283
$ env = null ;
Original file line number Diff line number Diff line change @@ -1403,6 +1403,20 @@ public function testSetBadEnv()
1403
1403
$ this ->assertSame ('' , $ process ->getErrorOutput ());
1404
1404
}
1405
1405
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
+
1406
1420
public function testInheritEnvEnabled ()
1407
1421
{
1408
1422
$ process = $ this ->getProcess (self ::$ phpBin .' -r ' .escapeshellarg ('echo serialize($_SERVER); ' ), null , array ('BAR ' => 'BAZ ' ));
You can’t perform that action at this time.
0 commit comments