From cf146c2f227e9763b5551f9910c9e11fdf36b26b Mon Sep 17 00:00:00 2001 From: Fred Cox Date: Fri, 13 Sep 2019 14:57:22 +0300 Subject: [PATCH] Allow correct environment to be loaded when .env.local.php exists This prevents surprises when you have generated the file, and then run your tests. --- symfony/framework-bundle/3.3/config/bootstrap.php | 2 +- symfony/framework-bundle/4.2/config/bootstrap.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/symfony/framework-bundle/3.3/config/bootstrap.php b/symfony/framework-bundle/3.3/config/bootstrap.php index beb52ca2b..78b63c265 100644 --- a/symfony/framework-bundle/3.3/config/bootstrap.php +++ b/symfony/framework-bundle/3.3/config/bootstrap.php @@ -6,7 +6,7 @@ // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) -if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { +if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) { foreach ($env as $k => $v) { $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v); } diff --git a/symfony/framework-bundle/4.2/config/bootstrap.php b/symfony/framework-bundle/4.2/config/bootstrap.php index 9c5a99c6e..976a77639 100644 --- a/symfony/framework-bundle/4.2/config/bootstrap.php +++ b/symfony/framework-bundle/4.2/config/bootstrap.php @@ -6,7 +6,7 @@ // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) -if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { +if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) { foreach ($env as $k => $v) { $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v); }