Skip to content

Commit cf146c2

Browse files
committed
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.
1 parent f9c6da3 commit cf146c2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

symfony/framework-bundle/3.3/config/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// Load cached env vars if the .env.local.php file exists
88
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9-
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
9+
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) {
1010
foreach ($env as $k => $v) {
1111
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
1212
}

symfony/framework-bundle/4.2/config/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// Load cached env vars if the .env.local.php file exists
88
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9-
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
9+
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) {
1010
foreach ($env as $k => $v) {
1111
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
1212
}

0 commit comments

Comments
 (0)