Skip to content

Commit d970c45

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Process] intersect with getenv() in case-insensitive manner to get default envs [Serializer] fix support for lazy/unset properties Fix redundant type casts [Notifier] Fix AllMySms bridge body content Revert "[DoctrineBridge] add support for the JSON type"
2 parents d44e6e0 + 5be20b3 commit d970c45

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Process.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ public function start(callable $callback = null, array $env = [])
302302
$descriptors = $this->getDescriptors();
303303

304304
if ($this->env) {
305-
$env += $this->env;
305+
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
306306
}
307307

308-
$env += $this->getDefaultEnv();
308+
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
309309

310310
if (\is_array($commandline = $this->commandline)) {
311311
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
@@ -1587,8 +1587,8 @@ private function replacePlaceholders(string $commandline, array $env)
15871587
private function getDefaultEnv(): array
15881588
{
15891589
$env = getenv();
1590-
$env = array_intersect_key($env, $_SERVER) ?: $env;
1590+
$env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
15911591

1592-
return $_ENV + $env;
1592+
return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
15931593
}
15941594
}

Tests/ProcessTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,18 @@ public function testWaitStoppedDeadProcess()
15221522
$this->assertFalse($process->isRunning());
15231523
}
15241524

1525+
public function testEnvCaseInsensitiveOnWindows()
1526+
{
1527+
$p = $this->getProcessForCode('print_r([$_SERVER[\'PATH\'] ?? 1, $_SERVER[\'Path\'] ?? 2]);', null, ['PATH' => 'bar/baz']);
1528+
$p->run(null, ['Path' => 'foo/bar']);
1529+
1530+
if ('\\' === \DIRECTORY_SEPARATOR) {
1531+
$this->assertSame('Array ( [0] => 1 [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput())));
1532+
} else {
1533+
$this->assertSame('Array ( [0] => bar/baz [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput())));
1534+
}
1535+
}
1536+
15251537
/**
15261538
* @param string|array $commandline
15271539
* @param mixed $input

0 commit comments

Comments
 (0)