bug #35022 [Dotenv] FIX missing getenv (mccullagh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Dotenv] FIX missing getenv

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no>
| Tickets       | Fix #34598
| License       | MIT
| Doc PR        |  -

Revert one line to use getenv because not all environment variables are populated in $_ENV[]

Commits
-------

9c5754acaa [Dotenv] FIX missing getenv
This commit is contained in:
Nicolas Grekas 2019-12-18 22:43:02 +01:00
commit b38aad5a39
2 changed files with 12 additions and 1 deletions

View File

@ -387,7 +387,7 @@ final class Dotenv
} elseif (isset($this->values[$name])) {
$value = $this->values[$name];
} else {
$value = '';
$value = (string) getenv($name);
}
if (!$matches['opening_brace'] && isset($matches['closing_brace'])) {

View File

@ -314,4 +314,15 @@ class DotenvTest extends TestCase
$this->assertSame('foo2_prod', $values['TEST2']);
}
}
public function testGetVariablesValueFromGetenv()
{
putenv('Foo=Bar');
$dotenv = new Dotenv(true);
$values = $dotenv->parse('Foo=${Foo}');
$this->assertSame('Bar', $values['Foo']);
putenv('Foo');
}
}