Skip to content

Commit 46b61fc

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (33 commits) do not pass a boolean to the constructor of the Dotenv class [Notifier] Fix low-deps tests Deprecate Composer 1 [Filesystem] Add third argument `$lockFile` to `Filesystem::appendToFile()` [TwigBundle] fix auto-enabling assets/expression/routing/yaml/workflow extensions [PhpUnitBridge] fix symlink to bridge in docker by making its path relative [Dotenv] Duplicate $_SERVER values in $_ENV if they don't exist Fix markup [Notifier] Add Expo bridge Add polish translations (#43725) Rename translation:update to translation:extract [String] Add PLURAL_MAP "zombies" -- fix #43789 Added support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller. [Validator] Update validators.bs.xlf Cache voters that will always abstain [Messenger] Fix `TraceableMessageBus` implementation so it can compute caller even when used within a callback [Validator] Add the missing translations for Russian (ru) [Validator] Added missing translations for Latvian (lv) [Validator] Added missing translations [Validator] Add missing translations for Vietnamese (VI) ...
2 parents 043988e + 0c5d051 commit 46b61fc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Dotenv.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,12 @@ public function populate(array $values, bool $overrideExistingVars = false): voi
182182

183183
foreach ($values as $name => $value) {
184184
$notHttpName = 0 !== strpos($name, 'HTTP_');
185+
if (isset($_SERVER[$name]) && $notHttpName && !isset($_ENV[$name])) {
186+
$_ENV[$name] = $_SERVER[$name];
187+
}
188+
185189
// don't check existence with getenv() because of thread safety issues
186-
if (!isset($loadedVars[$name]) && (!$overrideExistingVars && (isset($_ENV[$name]) || (isset($_SERVER[$name]) && $notHttpName)))) {
190+
if (!isset($loadedVars[$name]) && !$overrideExistingVars && isset($_ENV[$name])) {
187191
continue;
188192
}
189193

Tests/DotenvTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,16 @@ public function testDoNotUsePutenv()
539539
$this->assertFalse(getenv('TEST_USE_PUTENV'));
540540
}
541541

542+
public function testSERVERVarsDuplicationInENV()
543+
{
544+
unset($_ENV['SYMFONY_DOTENV_VARS'], $_SERVER['SYMFONY_DOTENV_VARS'], $_ENV['FOO']);
545+
$_SERVER['FOO'] = 'CCC';
546+
547+
(new Dotenv())->populate(['FOO' => 'BAR']);
548+
549+
$this->assertSame('CCC', $_ENV['FOO']);
550+
}
551+
542552
public function testBootEnv()
543553
{
544554
$resetContext = static function (): void {

0 commit comments

Comments
 (0)