From 1dfcdc7000bd9acc8c29b617e2d884fa34c04a66 Mon Sep 17 00:00:00 2001 From: Brieuc Thomas Date: Thu, 6 Jul 2017 14:23:24 +0200 Subject: [PATCH] [DotEnv] Fix variable substitution --- src/Symfony/Component/Dotenv/Dotenv.php | 2 +- src/Symfony/Component/Dotenv/Tests/DotenvTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 00f27bb7b3..2e907b8c98 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -351,7 +351,7 @@ final class Dotenv } $name = $matches[3]; - $value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? isset($_ENV[$name]) : (string) getenv($name)); + $value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? $_ENV[$name] : (string) getenv($name)); if (!$matches[2] && isset($matches[4])) { $value .= '}'; diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index a7f211ecd6..47598030a8 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -63,6 +63,7 @@ class DotenvTest extends TestCase public function getEnvData() { putenv('LOCAL=local'); + $_ENV['REMOTE'] = 'remote'; $tests = array( // spaces @@ -134,6 +135,7 @@ class DotenvTest extends TestCase array('FOO=" \\$ "', array('FOO' => ' $ ')), array('FOO=" $ "', array('FOO' => ' $ ')), array('BAR=$LOCAL', array('BAR' => 'local')), + array('BAR=$REMOTE', array('BAR' => 'remote')), array('FOO=$NOTDEFINED', array('FOO' => '')), );