8000 [HttpKernel] Add parameters `kernel.runtime_mode` and `kernel.runtime… · symfony/symfony@7c70aec · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c70aec

Browse files
[HttpKernel] Add parameters kernel.runtime_mode and kernel.runtime_mode.*, all set from env var APP_RUNTIME_MODE
1 parent 923ecdb commit 7c70aec

31 files changed

+62
-36
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
11761176
$container->setDefinition('debug.log_processor', $definition);
11771177

11781178
$container->register('debug.debug_logger_configurator', DebugLoggerConfigurator::class)
1179-
->setArguments([new Reference('debug.log_processor')]);
1179+
->setArguments([new Reference('debug.log_processor'), '%kernel.runtime_mode.web%']);
11801180
}
11811181
}
11821182

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

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
->tag('monolog.logger', ['channel' => 'php'])
3333

3434
->set('debug.debug_handlers_listener', DebugHandlersListener::class)
35+
->args([null, param('kernel.runtime_mode.web')])
3536
->tag('kernel.event_subscriber')
3637

3738
->set('debug.file_link_formatter', FileLinkFormatter::class)

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static function createSystemCache(string $namespace, int $defaultLifetime
9797
return $opcache;
9898
}
9999

100-
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
100+
if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
101101
return $opcache;
102102
}
103103

src/Symfony/Component/Cache/Adapter/ChainAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(array $adapters, int $defaultLifetime = 0)
5353
if (!$adapter instanceof CacheItemPoolInterface) {
5454
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class));
5555
}
56-
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
56+
if ('cli' === \PHP_SAPI && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
5757
continue; // skip putting APCu in the chain when the backend is disabled
5858
}
5959

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function isSupported()
6161
{
6262
self::$startTime ??= $_SERVER['REQUEST_TIME'] ?? time();
6363

64-
return \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL));
64+
return \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL));
6565
}
6666

6767
public function prune(): bool

src/Symfony/Component/Cache/Traits/ContractsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setCallbackWrapper(?callable $callbackWrapper): callable
4444
if (!isset($this->callbackWrapper)) {
4545
$this->callbackWrapper = LockRegistry::compute(...);
4646

47-
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
47+
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
4848
$this->setCallbackWrapper(null);
4949
}
5050
}

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class %s extends {$options['class']}
340340
341341
use Symfony\Component\DependencyInjection\Dumper\Preloader;
342342
343-
if (in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
343+
if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
344344
return;
345345
}
346346
@@ -388,6 +388,7 @@ class %s extends {$options['class']}
388388
'container.build_hash' => '$hash',
389389
'container.build_id' => '$id',
390390
'container.build_time' => $time,
391+
'container.runtime_mode' => \\in_array(\\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
391392
], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
392393
393394
EOF;
@@ -1591,7 +1592,7 @@ private function addDefaultParametersMethod(): string
15911592
$export = $this->exportParameters([$value], '', 12, $hasEnum);
15921593
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
15931594

1594-
if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w++'\)|targetDir\.'')/", $export[1])) {
1595+
if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w*+'\)|targetDir\.'')/", $export[1])) {
15951596
$dynamicPhp[$key] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
15961597
$this->dynamicParameters[$key] = true;
15971598
} else {

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): mixed
154154

155155
$returnNull = false;
156156
if ('' === $prefix) {
157+
if ('' === $name) {
158+
return null;
159+
}
157160
$returnNull = true;
158161
$prefix = 'string';
159162
}

src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function get(string $name): array|bool|string|int|float|\UnitEnum|null
4141
return $placeholder; // return first result
4242
}
4343
}
44-
if (!preg_match('/^(?:[-.\w\\\\]*+:)*+\w++$/', $env)) {
44+
if (!preg_match('/^(?:[-.\w\\\\]*+:)*+\w*+$/', $env)) {
4545
throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
4646
}
4747
if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) {

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10_as_files.txt

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ return new \Container%s\ProjectServiceContainer([
154154
'container.build_hash' => '%s',
155155
'container.build_id' => '%s',
156156
'container.build_time' => %d,
157+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
157158
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
158159

159160
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt

+1
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ return new \Container%s\ProjectServiceContainer([
787787
'container.build_hash' => '%s',
788788
'container.build_id' => '%s',
789789
'container.build_time' => %d,
790+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
790791
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
791792

792793
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ return new \Container%s\ProjectServiceContainer([
604604
'container.build_hash' => '%s',
605605
'container.build_id' => '%s',
606606
'container.build_time' => 1563381341,
607+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
607608
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
608609

609610
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories_with_tagged_iterrator.txt

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ return new \Container%s\ProjectServiceContainer([
119119
'container.build_hash' => '%s',
120120
'container.build_id' => '%s',
121121
'container.build_time' => %d,
122+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
122123
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
123124

124125
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ return new \Container%s\ProjectServiceContainer([
187187
'container.build_hash' => '%s',
188188
'container.build_id' => '%s',
189189
'container.build_time' => 1563381341,
190+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
190191
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
191192

192193
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deprecated_parameters_as_files.txt

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ return new \Container%s\ProjectServiceContainer([
195195
'container.build_hash' => '%s',
196196
'container.build_id' => '%s',
197197
'container.build_time' => %d,
198+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
198199
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
199200

200201
)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ return new \Container%s\Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File([
164164
'container.build_hash' => '%s',
165165
'container.build_id' => '%s',
166166
'container.build_time' => %d,
167+
'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1',
167168
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
168169

169170
)

src/Symfony/Component/ErrorHandler/Debug.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function enable(): ErrorHandler
2222
{
2323
error_reporting(-1);
2424

25-
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
25+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
2626
ini_set('display_errors', 0);
2727
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
2828
// CLI - display errors only if they're not already logged to STDERR

src/Symfony/Component/ErrorHandler/ErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ public static function handleFatalError(array $error = null): void
640640
*/
641641
private function renderException(\Throwable $exception): void
642642
{
643-
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
643+
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
644644

645645
$exception = $renderer->render($exception);
646646

src/Symfony/Component/HttpFoundation/Response.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public function send(/* bool $flush = true */): static
433433
fastcgi_finish_request();
434434
} elseif (\function_exists('litespeed_finish_request')) {
435435
litespeed_finish_request();
436-
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
436+
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
437437
static::closeOutputBuffers(0, true);
438438
flush();
439439
}

src/Symfony/Component/HttpKernel/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
* Add argument `$validationFailedStatusCode` to `#[MapQueryString]` and `#[MapRequestPayload]`
1212
* Add argument `$debug` to `Logger`
1313
* Add class `DebugLoggerConfigurator`
14+
* Add par 97AE ameters `kernel.runtime_mode` and `kernel.runtime_mode.*`, all set from env var `APP_RUNTIME_MODE`
1415
* Deprecate `Kernel::stripComments()`
1516
* Support the `!` character at the beginning of a string as a negation operator in the url filter of the profiler
1617
* Deprecate `UriSigner`, use `UriSigner` from the HttpFoundation component instead

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
4242
private ?RequestStack $requestStack;
4343
private DataDumperInterface|Connection|null $dumper;
4444
private mixed $sourceContextProvider;
45+
private bool $webMode;
4546

46-
public function __construct(Stopwatch $stopwatch = null, string|FileLinkFormatter $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, DataDumperInterface|Connection $dumper = null)
47+
public function __construct(Stopwatch $stopwatch = null, string|FileLinkFormatter $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, DataDumperInterface|Connection $dumper = null, bool $webMode = null)
4748
{
4849
$fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
4950
$this->stopwatch = $stopwatch;
5051
$this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter && false === $fileLinkFormat->format('', 0) ? false : $fileLinkFormat;
5152
$this->charset = $charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8';
5253
$this->requestStack = $requestStack;
5354
$this->dumper = $dumper;
55+
$this->webMode = $webMode ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true);
5456

5557
// All clones share these properties by reference:
5658
$this->rootRefs = [
@@ -231,7 +233,7 @@ public function __destruct()
231233
--$i;
232234
}
233235

234-
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) {
236+
if ($this->webMode) {
235237
$dumper = new HtmlDumper('php://output', $this->charset);
236238
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
237239
} else {

src/Symfony/Component/HttpKernel/DependencyInjection/LoggerPass.php

+1-12
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,7 @@ public function process(ContainerBuilder $container)
3737
return;
3838
}
3939

40-
if ($debug = $container->getParameter('kernel.debug')) {
41-
// Build an expression that will be equivalent to `!in_array(PHP_SAPI, ['cli', 'phpdbg'])`
42-
$debug = (new Definition('bool'))
43-
->setFactory('in_array')
44-
->setArguments([
45-
(new Definition('string'))->setFactory('constant')->setArguments(['PHP_SAPI']),
46-
['cli', 'phpdbg'],
47-
]);
48-
$debug = (new Definition('bool'))
49-
->setFactory('in_array')
50-
->setArguments([$debug, [false]]);
51-
}
40+
$debug = $container->getParameter('kernel.debug') && $container->getParameter('kernel.runtime_mode.web');
5241

5342
$container->register('logger', Logger::class)
5443
->setArguments([null, null, null, new Reference(RequestStack::class), $debug]);

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,29 @@ class DebugHandlersListener implements EventSubscriberInterface
3232
{
3333
private string|object|null $earlyHandler;
3434
private ?\Closure $exceptionHandler;
35+
private bool $webMode;
3536
private bool $firstCall = true;
3637
private bool $hasTerminatedWithException = false;
3738
3839
/**
3940
* @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception
4041
*/
41-
public function __construct(callable $exceptionHandler = null)
42+
public function __construct(callable $exceptionHandler = null, bool $webMode = null)
4243
{
4344
$handler = set_exception_handler('is_int');
4445
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
4546
restore_exception_handler();
4647

4748
$this->exceptionHandler = null === $exceptionHandler ? null : $exceptionHandler(...);
49+
$this->webMode = $webMode ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true);
4850
}
4951

5052
/**
5153
* Configures the error handler.
5254
*/
5355
public function configure(object $event = null): void
5456
{
55-
if ($event instanceof ConsoleEvent && !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
57+
if ($event instanceof ConsoleEvent && $this->webMode) {
5658
return;
5759
}
5860
if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMainRequest()) {

src/Symfony/Component/HttpKernel/Kernel.php

+4
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ protected function getKernelParameters(): array
570570
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
571571
'kernel.environment' => $this->environment,
572572
'kernel.runtime_environment' => '%env(default:kernel.environment:APP_RUNTIME_ENV)%',
573+
'kernel.runtime_mode' => '%env(query_string:default:container.runtime_mode:APP_RUNTIME_MODE)%',
574+
'kernel.runtime_mode.web' => '%env(bool:default::key:web:default:kernel.runtime_mode:)%',
575+
'kernel.runtime_mode.cli' => '%env(not:default:kernel.runtime_mode.web:)%',
576+
'kernel.runtime_mode.worker' => '%env(bool:default::key:worker:default:kernel.runtime_mode:)%',
573577
'kernel.debug' => $this->debug,
574578
'kernel.build_dir' => realpath($buildDir = $this->warmupDir ?: $this->getBuildDir()) ?: $buildDir,
575579
'kernel.cache_dir' => realpath($cacheDir = ($this->getCacheDir() === $this->getBuildDir() ? ($this->warmupDir ?: $this->getCacheDir()) : $this->getCacheDir())) ?: $cacheDir,

src/Symfony/Component/HttpKernel/Log/DebugLoggerConfigurator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DebugLoggerConfigurator
2222

2323
public function __construct(DebugLoggerInterface $processor, bool $enable = null)
2424
{
25-
if ($enable ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
25+
if ($enable ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
2626
$this->processor = $processor;
2727
}
2828
}

src/Symfony/Component/Routing/Router.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private function getConfigCacheFactory(): ConfigCacheFactoryInterface
343343

344344
private static function getCompiledRoutes(string $path): array
345345
{
346-
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) {
346+
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) {
347347
self::$cache = null;
348348
}
349349

src/Symfony/Component/Runtime/Internal/BasicErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function register(bool $debug): void
2222
{
2323
error_reporting(-1);
2424

25-
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
25+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
2626
ini_set('display_errors', $debug);
2727
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
2828
// CLI - display errors only if they're not already logged to STDERR

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\Runtime\Runner\Symfony;
1313

1414
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
1516
use Symfony\Component\HttpKernel\HttpKernelInterface;
17+
use Symfony\Component\HttpKernel\Kernel;
1618
use Symfony\Component\HttpKernel\TerminableInterface;
1719
use Symfony\Component\Runtime\RunnerInterface;
1820

@@ -31,7 +33,21 @@ public function __construct(
3133
public function run(): int
3234
{
3335
$response = $this->kernel->handle($this->request);
34-
$response->send(!$this->debug);
36+
37+
if (Kernel::VERSION_ID >= 60400) {
38+
$response->send(false);
39+
40+
if (\function_exists('fastcgi_finish_request') && !$this->debug) {
41+
fastcgi_finish_request();
42+
} elseif (\function_exists('litespeed_finish_request') && !$this->debug) {
43+
litespeed_finish_request();
44+
} else {
45+
Response::closeOutputBuffers(0, true);
46+
flush();
47+
}
48+
} else {
49+
$response->send();
50+
}
3551

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

src/Symfony/Component/Translation/Loader/PhpFileLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PhpFileLoader extends FileLoader
2222

2323
protected function loadResource(string $resource): array
2424
{
25-
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) {
25+
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL))) {
2626
self::$cache = null;
2727
}
2828

src/Symfony/Component/VarDumper/Resources/functions/dump.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function dump(mixed ...$vars): mixed
4545
if (!function_exists('dd')) {
4646
function dd(mixed ...$vars): never
4747
{
48-
if (!in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !headers_sent()) {
48+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) && !headers_sent()) {
4949
header('HTTP/1.1 500 Internal Server Error');
5050
}
5151

src/Symfony/Component/VarDumper/VarDumper.php

+3-3
DBEB
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ private static function register(): void
8585
case 'server' === $format:
8686
case $format && 'tcp' === parse_url($format, \PHP_URL_SCHEME):
8787
$host = 'server' === $format ? $_SERVER['VAR_DUMPER_SERVER'] ?? '127.0.0.1:9912' : $format;
88-
$dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliDumper() : new HtmlDumper();
88+
$dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliDumper() : new HtmlDumper();
8989
$dumper = new ServerDumper($host, $dumper, self::getDefaultContextProviders());
9090
break;
9191
default:
92-
$dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliDumper() : new HtmlDumper();
92+
$dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliDumper() : new HtmlDumper();
9393
}
9494

9595
if (!$dumper instanceof ServerDumper) {
@@ -111,7 +111,7 @@ private static function getDefaultContextProviders(): array
111111
{
112112
$contextProviders = [];
113113

114-
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && class_exists(Request::class)) {
114+
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) && class_exists(Request::class)) {
115115
$requestStack = new RequestStack();
116116
$requestStack->push(Request::createFromGlobals());
117117
$contextProviders['request'] = new RequestContextProvider($requestStack);

0 commit comments

Comments
 (0)
0