Skip to content

Commit 3c26de2

Browse files
bug #62661 [Runtime] Reuse the already created Request object when the app needs one as argument and returns a kernel (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [Runtime] Reuse the already created Request object when the app needs one as argument and returns a kernel | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #62643 | License | MIT Commits ------- c645717 [Runtime] Reuse the already created Request object when the app needs it as argument returns a kernel
2 parents 6382b38 + c645717 commit 3c26de2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/Runtime/SymfonyRuntime.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class SymfonyRuntime extends GenericRuntime
7070
private readonly ConsoleOutput $output;
7171
private readonly Application $console;
7272
private readonly Command $command;
73+
private readonly Request $request;
7374

7475
/**
7576
* @param array {
@@ -131,7 +132,7 @@ public function __construct(array $options = [])
131132
public function getRunner(?object $application): RunnerInterface
132133
{
133134
if ($application instanceof HttpKernelInterface) {
134-
return new HttpKernelRunner($application, Request::createFromGlobals(), $this->options['debug'] ?? false);
135+
return new HttpKernelRunner($application, $this->request ??= Request::createFromGlobals(), $this->options['debug'] ?? false);
135136
}
136137

137138
if ($application instanceof Response) {
@@ -179,7 +180,7 @@ public function getRunner(?object $application): RunnerInterface
179180
protected function getArgument(\ReflectionParameter $parameter, ?string $type): mixed
180181
{
181182
return match ($type) {
182-
Request::class => Request::createFromGlobals(),
183+
Request::class => $this->request ??= Request::createFromGlobals(),
183184
InputInterface::class => $this->getInput(),
184185
OutputInterface::class => $this->output ??= new ConsoleOutput(),
185186
Application::class => $this->console ??= new Application(),

0 commit comments

Comments
 (0)