Skip to content

Commit b9334ab

Browse files
committed
bug #52229 [FrameworkBundle] Fix CommandDataCollector is always registered (smnandre)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Fix CommandDataCollector is always registered | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52210 | License | MIT Another attempt at fixing #52210, allowing to revert #52218 and leave the conflict constraints untouched CommandDataCollector was always registered, and not always removed from the container when not needed/invalid. Commits ------- 6e2c2ec [FrameworkBundle] Fix CommandDataCollector is always registered
2 parents e6d1ed4 + 6e2c2ec commit b9334ab

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
861861
$loader->load('profiling.php');
862862
$loader->load('collectors.php');
863863
$loader->load('cache_debug.php');
864+
$loader->load('console_debug.php');
864865

865866
if ($this->isInitializedConfigEnabled('form')) {
866867
$loader->load('form_debug.php');
@@ -922,7 +923,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
922923
$container->removeDefinition('console_profiler_listener');
923924
}
924925

925-
if (!class_exists(CommandDataCollector::class)) {
926+
if (!$container->getParameter('kernel.debug') || !class_exists(CliRequest::class) || !class_exists(CommandDataCollector::class)) {
926927
$container->removeDefinition('.data_collector.command');
927928
}
928929
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector;
15-
use Symfony\Component\Console\DataCollector\CommandDataCollector;
1615
use Symfony\Component\HttpKernel\DataCollector\AjaxDataCollector;
1716
use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
1817
use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;
@@ -75,8 +74,5 @@
7574
->set('data_collector.router', RouterDataCollector::class)
7675
->tag('kernel.event_listener', ['event' => KernelEvents::CONTROLLER, 'method' => 'onKernelController'])
7776
->tag('data_collector', ['template' => '@WebProfiler/Collector/router.html.twig', 'id' => 'router', 'priority' => 285])
78-
79-
->set('.data_collector.command', CommandDataCollector::class)
80-
->tag('data_collector', ['template' => '@WebProfiler/Collector/command.html.twig', 'id' => 'command', 'priority' => 335])
8177
;
8278
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\Console\DataCollector\CommandDataCollector;
15+
16+
return static function (ContainerConfigurator $container) {
17+
$container->services()
18+
->set('.data_collector.command', CommandDataCollector::class)
19+
->tag('data_collector', ['template' => '@WebProfiler/Collector/command.html.twig', 'id' => 'command', 'priority' => 335])
20+
;
21+
};

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"symfony/twig-bridge": "<5.4",
102102
"symfony/twig-bundle": "<5.4",
103103
"symfony/validator": "<6.4",
104-
"symfony/web-profiler-bundle": "<6.4",
104+
"symfony/web-profiler-bundle": "<5.4",
105105
"symfony/workflow": "<6.4"
106106
},
107107
"autoload": {

0 commit comments

Comments
 (0)