<p dir="auto"><a href="https://github.com/symfony/symfony/pull/19681" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/19681/hovercard">The pull request</a> to allow injecting ENV parameters introduced an issue when building the container.</p>
<p dir="auto">When a container is merged, the <code class="notranslate">mergeEnvPlaceholders</code> will duplicate existing placeholders. In a local project, where I had 9 <code class="notranslate">env()</code> parameters, this meant that the first 3 were duplicated 32768 times. Later when the compiler calls <code class="notranslate">resolveEnvPlaceholders</code> it will loop through all of these impacting performance pretty badly.</p>
<p dir="auto">I think the problem is that using <code class="notranslate">array_merge_recursive</code> will <a href="http://php.net/manual/en/function.array-merge-recursive.php" rel="nofollow">append duplicate values of nested arrays if the keys are numeric</a>. I've never contributed to Symfony before so I'm not sure on this one, but I don't know if it needs to be fully recursive given that the environment placeholders should be scalar values.</p>
<p dir="auto">If it really does need to be recursive then something like <a href="http://php.net/manual/en/function.array-merge-recursive.php#92195" rel="nofollow">the function mentioned</a> in the comments for the <code class="notranslate">array_merge_recursive</code> docs page could be used. I did a simple performance check (microtime) for one of the compiler passes that was slowing down (ContainerBuilderDebugDumpPass)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0.023882150650024 # with the function from the comments in the php docs
16.744822025299 # as it is now
0.023157119750977 # with only one level merge"><pre class="notranslate"><code class="notranslate">0.023882150650024 # with the function from the comments in the php docs
16.744822025299 # as it is now
0.023157119750977 # with only one level merge
</code></pre></div>
<p dir="auto">I'll create a pull request using the simple merge and see what you think.</p>
<p dir="auto">I guess this won't affect anything before v3.2</p>
<p dir="auto">The FileType currently prints the full qualified file system path to a file into the value attribute of the input field. This should be prevented at all costs inside the FileType (not in the template).</p>