[Dotenv] dont use getenv() to read SYMFONY_DOTENV_VARS
This commit is contained in:
parent
6006448997
commit
21a909a189
@ -66,8 +66,8 @@ final class Dotenv
|
||||
*/
|
||||
public function populate($values)
|
||||
{
|
||||
$loadedVars = array_flip(explode(',', getenv('SYMFONY_DOTENV_VARS')));
|
||||
unset($loadedVars['']);
|
||||
$updateLoadedVars = false;
|
||||
$loadedVars = array_flip(explode(',', isset($_SERVER['SYMFONY_DOTENV_VARS']) ? $_SERVER['SYMFONY_DOTENV_VARS'] : (isset($_ENV['SYMFONY_DOTENV_VARS']) ? $_ENV['SYMFONY_DOTENV_VARS'] : '')));
|
||||
|
||||
foreach ($values as $name => $value) {
|
||||
$notHttpName = 0 !== strpos($name, 'HTTP_');
|
||||
@ -82,14 +82,15 @@ final class Dotenv
|
||||
$_SERVER[$name] = $value;
|
||||
}
|
||||
|
||||
$loadedVars[$name] = true;
|
||||
if (!isset($loadedVars[$name])) {
|
||||
$loadedVars[$name] = $updateLoadedVars = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($loadedVars) {
|
||||
if ($updateLoadedVars) {
|
||||
unset($loadedVars['']);
|
||||
$loadedVars = implode(',', array_keys($loadedVars));
|
||||
putenv("SYMFONY_DOTENV_VARS=$loadedVars");
|
||||
$_ENV['SYMFONY_DOTENV_VARS'] = $loadedVars;
|
||||
$_SERVER['SYMFONY_DOTENV_VARS'] = $loadedVars;
|
||||
putenv('SYMFONY_DOTENV_VARS='.$_ENV['SYMFONY_DOTENV_VARS'] = $_SERVER['SYMFONY_DOTENV_VARS'] = $loadedVars);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ class DotenvTest extends TestCase
|
||||
|
||||
public function testOverridingEnvVarsWithNamesMemorizedInSpecialVar()
|
||||
{
|
||||
putenv('SYMFONY_DOTENV_VARS=FOO,BAR,BAZ');
|
||||
putenv('SYMFONY_DOTENV_VARS='.$_SERVER['SYMFONY_DOTENV_VARS'] = 'FOO,BAR,BAZ');
|
||||
|
||||
putenv('FOO=foo');
|
||||
putenv('BAR=bar');
|
||||
|
Reference in New Issue
Block a user