8000 [FrameworkBundle] Fixed issue when a parameter container a '%' · symfony/symfony@53b0501 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53b0501

Browse files
committed
[FrameworkBundle] Fixed issue when a parameter container a '%'
On my computer: ``` dump(get_cfg_var('xdebug.file_link_format')); "subl://%f:%l" ``` When I ran `bin/console debug:config framework` I got this exception: ``` In ParameterBag.php line 100: [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] The parameter "templating.helper.code.file_link_format" has a dependency on a non-existent parameter "f:". Exception trace: () at /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:100 ... ``` This issue was introduced [here](https://github.com/symfony/symfony/pull/27684/files#diff-b3847149480405e1de881530b4c75ab5L212)
1 parent 4f290d7 commit 53b0501

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,12 @@ protected function getContainerBuilder()
224224
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
225225
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
226226
$container = $buildContainer();
227+
$container->getCompilerPassConfig()->setRemovingPasses([]);
228+
$container->compile();
227229
} else {
228230
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
229-
$container->setParameter('container.build_hash', $hash = ContainerBuilder::hash(__METHOD__));
230-
$container->setParameter('container.build_id', hash('crc32', $hash.time()));
231231
}
232232

233-
$container->getCompilerPassConfig()->setRemovingPasses([]);
234-
$container->compile();
235-
236233
return $this->containerBuilder = $container;
237234
}
238235

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,27 @@ public static function getClassDescription(string $class, string &$resolvedClass
322322

323323
private function getContainerEnvVars(ContainerBuilder $container): array
324324
{
325+
$bag = $container->getParameterBag();
326+
$getDefaultParamter = function (string $name) {
327+
return parent::get($name);
328+
};
329+
$getDefaultParamter = $getDefaultParamter->bindTo($bag, \get_class($bag));
330+
331+
$file = file_get_contents($container->getParameter('debug.container.dump'));
332+
333+
preg_match_all('{%env\((.*)\)%}', $file, $envVars);
334+
$envVars = array_unique($envVars[1]);
335+
325336
$getEnvReflection = new \ReflectionMethod($container, 'getEnv');
326337
$getEnvReflection->setAccessible(true);
327-
$envs = [];
328-
foreach (array_keys($container->getEnvCounters()) as $env) {
338+
339+
foreach ($envVars as $env) {
329340
$processor = 'string';
330341
if (false !== $i = strrpos($name = $env, ':')) {
331342
$name = substr($env, $i + 1);
332343
$processor = substr($env, 0, $i);
333344
}
334-
$defaultValue = ($hasDefault = $container->hasParameter("env($name)")) ? $container->getParameter("env($name)") : null;
345+
$defaultValue = ($hasDefault = $container->hasParameter("env($name)")) ? $getDefaultParamter("env($name)") : null;
335346
if (false === ($runtimeValue = $_ENV[$name] ?? $_SERVER[$name] ?? getenv($name))) {
336347
$runtimeValue = null;
337348
}

0 commit comments

Comments
 (0)
0