Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03adce2

Browse filesBrowse files
[Process] Fix setting empty env vars
1 parent 6935e5a commit 03adce2
Copy full SHA for 03adce2

File tree

2 files changed

+12
-4
lines changed
Filter options

2 files changed

+12
-4
lines changed

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,16 @@ public function start(callable $callback = null/*, array $env = array()*/)
326326
// @see : https://bugs.php.net/69442
327327
$ptsWorkaround = fopen(__FILE__, 'r');
328328
}
329+
if (defined('HHVM_VERSION')) {
330+
$envPairs = $env;
331+
} else {
332+
$envPairs = array();
333+
foreach ($env as $k => $v) {
334+
$envPairs[] = $k.'='.$v;
335+
}
336+
}
329337

330-
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $this->options);
338+
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
331339

332340
if (!is_resource($this->process)) {
333341
throw new RuntimeException('Unable to launch a new process.');

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ProcessTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,14 +1423,14 @@ public function testEnvBackupDoesNotDeleteExistingVars()
14231423

14241424
public function testEnvIsInherited()
14251425
{
1426-
$process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ'));
1426+
$process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ', 'EMPTY' => ''));
14271427

14281428
putenv('FOO=BAR');
14291429
$_ENV['FOO'] = 'BAR';
14301430

14311431
$process->run();
14321432

1433-
$expected = array('BAR' => 'BAZ', 'FOO' => 'BAR');
1433+
$expected = array('BAR' => 'BAZ', 'EMPTY' => '', 'FOO' => 'BAR');
14341434
$env = array_intersect_key(unserialize($process->getOutput()), $expected);
14351435

14361436
$this->assertEquals($expected, $env);
@@ -1511,7 +1511,7 @@ public function testRawCommandLine()
15111511
)
15121512
15131513
EOTXT;
1514-
$this->assertSame($expected, $p->getOutput());
1514+
$this->assertSame($expected, str_replace('Standard input code', '-', $p->getOutput()));
15151515
}
15161516

15171517
public function provideEscapeArgument()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.