Skip to content

Commit 5bc7acf

Browse files
minor #44876 [DependencyInjection] Optimization of resolveEnvPlaceholders (vladimir.panivko)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Optimization of resolveEnvPlaceholders | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT When you have to much env variables and many services in your container, container compilаtion can take much time due to the function stripos which is called much time. Look at the bottom of picture https://i2.piccy.info/i9/cdc413af9aecce8f7ed5ca0fe69b6c7c/1640950765/149173/1453384/6833Screenshot_from_2021_12_31_13_38_20.png It happens because function resolveEnvPlaceholders try to find env placeholders in any value, even when there is no possible env in string. So i offer to check value on strings env_ or env( and if they are present than look for placeholders. In my project it helps me to save 10 seconds in container building. Commits ------- f73b5aa479 Optimization of resolveEnvPlaceholders
2 parents 1ae7617 + 74e2bf5 commit 5bc7acf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
14131413
return $result;
14141414
}
14151415

1416-
if (!\is_string($value) || 38 > \strlen($value)) {
1416+
if (!\is_string($value) || 38 > \strlen($value) || !preg_match('/env[_(]/i', $value)) {
14171417
return $value;
14181418
}
14191419
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;

0 commit comments

Comments
 (0)