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
This commit is contained in:
Nicolas Grekas 2017-12-20 13:20:53 +01:00
commit 6935e5a4aa

View File

@ -1718,15 +1718,11 @@ class Process implements \IteratorAggregate
private function getDefaultEnv()
{
if (\PHP_VERSION_ID >= 70100) {
$env = getenv();
} else {
$env = array();
$env = array();
foreach ($_SERVER as $k => $v) {
if (is_string($v) && false !== $v = getenv($k)) {
$env[$k] = $v;
}
foreach ($_SERVER as $k => $v) {
if (is_string($v) && false !== $v = getenv($k)) {
$env[$k] = $v;
}
}