8000 [HttpFoundation][Runtime] Do not call *_finish_request() functions wh… · symfony/symfony@be1e3bc · GitHub
[go: up one dir, main page]

Skip to content

Commit be1e3bc

Browse files
committed
[HttpFoundation][Runtime] Do not call *_finish_request() functions when debug mode is on
1 parent f13a4b1 commit be1e3bc

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

src/Symfony/Component/HttpFoundation/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Support root-level `Generator` in `StreamedJsonResponse`
99
* Add `UriSigner` from the HttpKernel component
1010
* Add `partitioned` flag to `Cookie` (CHIPS Cookie)
11+
* Add argument `bool $finishRequest = true` to `Response::send()`
1112

1213
6.3
1314
---

src/Symfony/Component/HttpFoundation/Response.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,18 @@ public function sendContent(): static
415415
/**
416416
* Sends HTTP headers and content.
417417
*
418+
* @param bool $finishRequest Whether fastcgi_finish_request() and alike functions should be called or not
419+
*
418420
* @return $this
419421
*/
420-
public function send(): static
422+
public function send(/* bool $finishRequest = true */): static
421423
{
422424
$this->sendHeaders();
423425
$this->sendContent();
424426

425-
if (\function_exists('fastcgi_finish_request')) {
427+
if (\function_exists('fastcgi_finish_request') && (1 <= \func_num_args() ? func_get_arg(0) : true)) {
426428
fastcgi_finish_request();
427-
} elseif (\function_exists('litespeed_finish_request')) {
429+
} elseif (\function_exists('litespeed_finish_request') && (1 <= \func_num_args() ? func_get_arg(0) : true)) {
428430
litespeed_finish_request();
429431
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
430432
static::closeOutputBuffers(0, true);

src/Symfony/Component/Runtime/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Add argument `bool $debug = false` to `HttpKernelRunner::__construct()`
8+
49
5.4
510
---
611

src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ class HttpKernelRunner implements RunnerInterface
2424
public function __construct(
2525
private readonly HttpKernelInterface $kernel,
2626
private readonly Request $request,
27+
private readonly bool $debug = false,
2728
) {
2829
}
2930

3031
public function run(): int
3132
{
3233
$response = $this->kernel->handle($this->request);
33-
$response->send();
34+
$response->send(!$this->debug);
3435

3536
if ($this->kernel instanceof TerminableInterface) {
3637
$this->kernel->terminate($this->request, $response);

src/Symfony/Component/Runtime/SymfonyRuntime.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function __construct(array $options = [])
131131
public function getRunner(?object $application): RunnerInterface
132132
{
133133
if ($application instanceof HttpKernelInterface) {
134-
return new HttpKernelRunner($application, Request::createFromGlobals());
134+
return new HttpKernelRunner($application, Request::createFromGlobals(), $this->options['debug'] ?? false);
135135
}
136136

137137
if ($application instanceof Response) {

0 commit comments

Comments
 (0)
0