Skip to content

Commit aaafad1

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

31 files changed

+62
-36
lines changed

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

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

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

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

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

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

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

Lines changed: 3 additions & 2 deletions
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

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

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

Lines changed: 1 addition & 0 deletions
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) ? 'cli' : 'web',
157158
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
158159

159160
)

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