Skip to content

Commit

Permalink
[HttpKernel] Add parameters kernel.runtime_mode and `kernel.runtime…
Browse files Browse the repository at this point in the history
…_mode.*`, all set from env var `APP_RUNTIME_MODE`
  • Loading branch information
nicolas-grekas committed Oct 18, 2023
1 parent a406f2d commit 8653923
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Internal/BasicErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function register(bool $debug): void
{
error_reporting(-1);

if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
ini_set('display_errors', $debug);
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
// CLI - display errors only if they're not already logged to STDERR
Expand Down
18 changes: 17 additions & 1 deletion Runner/Symfony/HttpKernelRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
namespace Symfony\Component\Runtime\Runner\Symfony;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\TerminableInterface;
use Symfony\Component\Runtime\RunnerInterface;

Expand All @@ -31,7 +33,21 @@ public function __construct(
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send(!$this->debug);

if (Kernel::VERSION_ID >= 60400) {
$response->send(false);

if (\function_exists('fastcgi_finish_request') && !$this->debug) {
fastcgi_finish_request();
} elseif (\function_exists('litespeed_finish_request') && !$this->debug) {
litespeed_finish_request();
} else {
Response::closeOutputBuffers(0, true);
flush();
}
} else {
$response->send();
}

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

0 comments on commit 8653923

Please sign in to comment.