8000 [Process] Fix Process::getEnv() when setEnv() hasn't been called before by asika32764 · Pull Request #45931 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] Fix Process::getEnv() when setEnv() hasn't been called before #45931

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 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
[Process] Fix Process::getEnv() when setEnv() hasn't been called before
  • Loading branch information
asika32764 authored and nicolas-grekas committed Apr 4, 2022
commit a5bf7407de0a608f130c1c4c62ecbb4f9101bac7
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Process implements \IteratorAggregate
private $hasCallback = false;
private $commandline;
private $cwd;
private $env;
private $env = [];
private $input;
private $starttime;
private $lastOutputTime;
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Component/Process/Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,11 @@ public function testPreparedCommandWithNoValues()

public function testEnvArgument()
{
$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
$cmd = '\\' === \DIRECTORY_SEPARATOR ? 'echo !FOO! !BAR! !BAZ!' : 'echo $FOO $BAR $BAZ';
$p = Process::fromShellCommandline($cmd);
$this->assertSame([], $p->getEnv());

$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
$p = Process::fromShellCommandline($cmd, null, $env);
$p->run(null, ['BAR' => 'baR', 'BAZ' => 'baZ']);

Expand Down
0