Skip to content

Commit

Permalink
Merge branch '4.4' into 5.3
Browse files Browse the repository at this point in the history
* 4.4: (22 commits)
  [PhpUnitBridge] fix symlink to bridge in docker by making its path relative
  [Dotenv] Duplicate $_SERVER values in $_ENV if they don't exist
  Add polish translations (#43725)
  [Validator] Update validators.bs.xlf
  [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)
  Add missing translations for Lithuanian (lt)
  [Validator] Add missing translations for Italian (it) #43722
  Add missing translations for Ukrainian
  Add missing translations for Bulgarian
  Add missing translations for Dutch (nl)
  Update validators.es.xlf
  update zh_TW translation
  [Validator] Added Danish translations
  added missing translations for Serbian Latin (sr_Latn) #43734
  [Validator] Added Chinese(zh_CN) translations
  [Validator] Add missing Hungarian translations
  ...
  • Loading branch information
derrabus committed Oct 28, 2021
2 parents 46a528c + de87d7b commit 6633083
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ public function populate(array $values, bool $overrideExistingVars = false): voi

foreach ($values as $name => $value) {
$notHttpName = 0 !== strpos($name, 'HTTP_');
if (isset($_SERVER[$name]) && $notHttpName && !isset($_ENV[$name])) {
$_ENV[$name] = $_SERVER[$name];
}

// don't check existence with getenv() because of thread safety issues
if (!isset($loadedVars[$name]) && (!$overrideExistingVars && (isset($_ENV[$name]) || (isset($_SERVER[$name]) && $notHttpName)))) {
if (!isset($loadedVars[$name]) && !$overrideExistingVars && isset($_ENV[$name])) {
continue;
}

Expand Down
10 changes: 10 additions & 0 deletions Tests/DotenvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ public function testDoNotUsePutenv()
$this->assertFalse(getenv('TEST_USE_PUTENV'));
}

public function testSERVERVarsDuplicationInENV()
{
unset($_ENV['SYMFONY_DOTENV_VARS'], $_SERVER['SYMFONY_DOTENV_VARS'], $_ENV['FOO']);
$_SERVER['FOO'] = 'CCC';

(new Dotenv(false))->populate(['FOO' => 'BAR']);

$this->assertSame('CCC', $_ENV['FOO']);
}

public function testBootEnv()
{
$resetContext = static function (): void {
Expand Down

0 comments on commit 6633083

Please sign in to comment.