Skip to content

Commit 8da05da

Browse files
committed
[HttpFoundation][Runtime] Do not call *_finish_request() functions when debug mode is on
1 parent 3fb0e11 commit 8da05da

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,19 @@ 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
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+
$finishRequest = 1 <= \func_num_args() ? func_get_arg(0) : true;
428+
if (\function_exists('fastcgi_finish_request') && $finishRequest) {
426429
fastcgi_finish_request();
427-
} elseif (\function_exists('litespeed_finish_request')) {
430+
} elseif (\function_exists('litespeed_finish_request') && $finishRequest) {
428431
litespeed_finish_request();
429432
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
430433
static::closeOutputBuffers(0, true);

src/Symfony/Component/Runtime/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy