Skip to content

Commit c579806

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Process] filter env vars for "argc" & "argv" specifically [Process] exclude argv/argc from possible default env vars [HttpClient] fix closing curl multi handle when destructing client [Validator] Add missing Czech translations
2 parents bcf5440 + 762e4f7 commit c579806

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

Process.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public function start(callable $callback = null, array $env = [])
335335

336336
$envPairs = [];
337337
foreach ($env as $k => $v) {
338-
if (false !== $v) {
338+
if (false !== $v && 'argc' !== $k && 'argv' !== $k) {
339339
$envPairs[] = $k.'='.$v;
340340
}
341341
}
@@ -1089,25 +1089,12 @@ public function getEnv(): array
10891089
/**
10901090
* Sets the environment variables.
10911091
*
1092-
* Each environment variable value should be a string.
1093-
* If it is an array, the variable is ignored.
1094-
* If it is false or null, it will be removed when
1095-
* env vars are otherwise inherited.
1096-
*
1097-
* That happens in PHP when 'argv' is registered into
1098-
* the $_ENV array for instance.
1099-
*
1100-
* @param array $env The new environment variables
1092+
* @param array<string|\Stringable> $env The new environment variables
11011093
*
11021094
* @return $this
11031095
*/
11041096
public function setEnv(array $env): static
11051097
{
1106-
// Process cannot handle env values that are arrays
1107-
$env = array_filter($env, function ($value) {
1108-
return !\is_array($value);
1109-
});
1110-
11111098
$this->env = $env;
11121099

11131100
return $this;
@@ -1602,12 +1589,6 @@ private function getDefaultEnv(): array
16021589
$env = getenv();
16031590
$env = array_intersect_key($env, $_SERVER) ?: $env;
16041591

1605-
foreach ($_ENV as $k => $v) {
1606-
if (\is_string($v)) {
1607-
$env[$k] = $v;
1608-
}
1609-
}
1610-
1611-
return $env;
1592+
return $_ENV + $env;
16121593
}
16131594
}

0 commit comments

Comments
 (0)