Skip to content

Commit 6935e5a

Browse files
bug #25559 [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25511 | License | MIT | Doc PR | - Commits ------- 0d4bce6 [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions
2 parents d731a27 + 0d4bce6 commit 6935e5a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,15 +1718,11 @@ private function escapeArgument($argument)
17181718

17191719
private function getDefaultEnv()
17201720
{
1721-
if (\PHP_VERSION_ID >= 70100) {
1722-
$env = getenv();
1723-
} else {
1724-
$env = array();
1721+
$env = array();
17251722

1726-
foreach ($_SERVER as $k => $v) {
1727-
if (is_string($v) && false !== $v = getenv($k)) {
1728-
$env[$k] = $v;
1729-
}
1723+
foreach ($_SERVER as $k => $v) {
1724+
if (is_string($v) && false !== $v = getenv($k)) {
1725+
$env[$k] = $v;
17301726
}
17311727
}
17321728

0 commit comments

Comments
 (0)