Skip to content

Commit 365a469

Browse files
Merge branch '4.4'
* 4.4: (23 commits) [HttpFoundation] fix docblock [HttpKernel] Flatten "exception" controller argument if not typed Fix MySQL column type definition. Link the right file depending on the new version [Cache] Redis Tag Aware warn on wrong eviction policy [HttpClient] fix HttpClientDataCollector [HttpKernel] collect bundle classes, not paths [Config] fix id-generation for GlobResource [HttpKernel] dont check cache freshness more than once per process [Finder] Allow ssh2 stream wrapper for sftp [FrameworkBundle] fix wiring of httplug client add FrameworkBundle requirement [SecurityBundle] add tests with empty authenticator [Security] always check the token on non-lazy firewalls [DI] Use reproducible entropy to generate env placeholders [WebProfilerBundle] Require symfony/twig-bundle [Mailer] Add UPGRADE entry about the null transport DSN bumped Symfony version to 4.3.9 updated VERSION for 4.3.8 updated CHANGELOG for 4.3.8 ...
2 parents 3264d0a + baac36a commit 365a469

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ParameterBag/EnvPlaceholderParameterBag.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class EnvPlaceholderParameterBag extends ParameterBag
2424
private $unusedEnvPlaceholders = [];
2525
private $providedTypes = [];
2626

27+
private static $counter = 0;
28+
2729
/**
2830
* {@inheritdoc}
2931
*/
@@ -49,7 +51,7 @@ public function get(string $name)
4951
throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
5052
}
5153

52-
$uniqueName = md5($name.uniqid(mt_rand(), true));
54+
$uniqueName = md5($name.'_'.self::$counter++);
5355
$placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), str_replace(':', '_', $env), $uniqueName);
5456
$this->envPlaceholders[$env][$placeholder] = $placeholder;
5557

@@ -64,7 +66,13 @@ public function get(string $name)
6466
*/
6567
public function getEnvPlaceholderUniquePrefix(): string
6668
{
67-
return $this->envPlaceholderUniquePrefix ?? $this->envPlaceholderUniquePrefix = 'env_'.bin2hex(random_bytes(8));
69+
if (null === $this->envPlaceholderUniquePrefix) {
70+
$reproducibleEntropy = unserialize(serialize($this->parameters));
71+
array_walk_recursive($reproducibleEntropy, function (&$v) { $v = null; });
72+
$this->envPlaceholderUniquePrefix = 'env_'.substr(md5(serialize($reproducibleEntropy)), -16);
73+
}
74+
75+
return $this->envPlaceholderUniquePrefix;
6876
}
6977

7078
/**

0 commit comments

Comments
 (0)