8000 bug #52966 [FrameworkBundle] Fix profiling command in web context (He… · symfony/symfony@f0099d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0099d9

Browse files
bug #52966 [FrameworkBundle] Fix profiling command in web context (HeahDude)
This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Fix profiling command in web context | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52925 | License | MIT Commits ------- 8a1ced3 [FrameworkBundle] Fix profiling command in web context
2 parents f58cf04 + 8a1ced3 commit f0099d9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function __construct(
4242
private readonly Profiler $profiler,
4343
private readonly RequestStack $requestStack,
4444
private readonly Stopwatch $stopwatch,
45+
private readonly bool $cliMode,
4546
private readonly UrlGeneratorInterface $urlGenerator,
4647
) {
4748
$this->profiles = new \SplObjectStorage();
@@ -59,6 +60,10 @@ public static function getSubscribedEvents(): array
5960

6061
public function initialize(ConsoleCommandEvent $event): void
6162
{
63+
if (!$this->cliMode) {
64+
return;
65+
}
66+
6267
$input = $event->getInput();
6368
if (!$input->hasOption('profile') || !$input->getOption('profile')) {
6469
$this->profiler->disable();
@@ -78,12 +83,16 @@ public function initialize(ConsoleCommandEvent $event): void
7883

7984
public function catch(ConsoleErrorEvent $event): void
8085
{
86+
if (!$this->cliMode) {
87+
return;
88+
}
89+
8190
$this->error = $event->getError();
8000
8291
}
8392

8493
public function profile(ConsoleTerminateEvent $event): void
8594
{
86-
if (!$this->profiler->isEnabled()) {
95+
if (!$this->cliMode || !$this->profiler->isEnabled()) {
8796
return;
8897
}
8998

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
service('profiler'),
4444
service('.virtual_request_stack'),
4545
service('debug.stopwatch'),
46+
param('kernel.runtime_mode.cli'),
4647
service('router'),
4748
])
4849
->tag('kernel.event_subscriber')

0 commit comments

Comments
 (0)
0