8000 bug #52963 [FrameworkBundle] Fix profiling commands without router (H… · WoutervanderLoopNL/symfony@fec8909 · GitHub
[go: up one dir, main page]

Skip to content

Commit fec8909

Browse files
committed
bug symfony#52963 [FrameworkBundle] Fix profiling commands without router (HeahDude)
This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Fix profiling commands without router | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | symfony#52943 | License | MIT Commits ------- 7fba074 [FrameworkBundle] Fix profiling commands without router
2 parents f0099d9 + 7fba074 commit fec8909

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
private readonly RequestStack $requestStack,
4444
private readonly Stopwatch $stopwatch,
4545
private readonly bool $cliMode,
46-
private readonly UrlGeneratorInterface $urlGenerator,
46+
private readonly ?UrlGeneratorInterface $urlGenerator = null,
4747
) {
4848
$this->profiles = new \SplObjectStorage();
4949
$this->parents = new \SplObjectStorage();
@@ -140,12 +140,14 @@ public function profile(ConsoleTerminateEvent $event): void
140140
$p = $this->profiles[$r];
141141
$this->profiler->saveProfile($p);
142142

143-
$token = $p->getToken();
144-
$output?->writeln(sprintf(
145-
'See profile <href=%s>%s</>',
146-
$this->urlGenerator->generate('_profiler', ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL),
147-
$token
148-
));
143+
if ($this->urlGenerator && $output) {
144+
$token = $p->getToken();
145+
$output->writeln(sprintf(
146+
'See profile <href=%s>%s</>',
147+
$this->urlGenerator->generate('_profiler', ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL),
148+
$token
149+
));
150+
}
149151
}
150152

151153
$this->profiles = new \SplObjectStorage();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
service('.virtual_request_stack'),
4545
service('debug.stopwatch'),
4646
param('kernel.runtime_mode.cli'),
47-
service('router'),
47+
service('router')->nullOnInvalid(),
4848
])
4949
->tag('kernel.event_subscriber')
5050

0 commit comments

Comments
 (0)
0