[HttpKernel] Add parameters kernel.runtime_mode and kernel.runtime_mode.*, all set from env var APP_RUNTIME_MODE#52079
Conversation
5e777ad to
1387951
Compare
src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
Outdated
Show resolved
Hide resolved
1387951 to
9cb05e6
Compare
9cb05e6 to
54ed084
Compare
|
shouldn't the error rendering depend on web_mode ? For a long-running server, we would want to provide the web error rendering. |
yes, but it's too much work for me for now, could be handled later on (same for cache locking, see PR description) |
kernel.runtime_mode, defined as %env(default:container.runtime_mode:APP_RUNTIME_MODE)%kernel.runtime_mode and kernel.runtime_mode.*, all set from env var APP_RUNTIME_MODE
54ed084 to
aaafad1
Compare
|
PR updated. No special service anymore, only parameters. Here is the new description: Here, we ensure that the kernel always provides a new This also creates 3 new parameters that should be the most common: A long-running server would typically set |
| } | ||
|
|
||
| if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) { | ||
| if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) { |
There was a problem hiding this comment.
aligning with other checks we have in place for APCu (not need to enable it for phpdbg/embed)
| $export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2); | ||
|
|
||
| if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w++'\)|targetDir\.'')/", $export[1])) { | ||
| if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w*+'\)|targetDir\.'')/", $export[1])) { |
There was a problem hiding this comment.
this change allows to derivate dynamic parameters from other ones, eg %env(key:foo:default:bar:)% extracts key foo from parameter bar (which is supposed to be an array here)
…_mode.*`, all set from env var `APP_RUNTIME_MODE`
aaafad1 to
7c70aec
Compare
| } elseif (\function_exists('litespeed_finish_request') && !$this->debug) { | ||
| litespeed_finish_request(); | ||
| } else { | ||
| Response::closeOutputBuffers(0, true); |
There was a problem hiding this comment.
Unlike the logic in $response->send(), we call this unconditionally. The reason is that here, in the runtime, we know we want to flush whatever the SAPI.
|
Thank you @nicolas-grekas. |
…t (HypeMC) This PR was merged into the 6.4 branch. Discussion ---------- [DebugBundle] Wire `DumpDataCollector`'s `webMode` argument | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | maybe | New feature? | no | Deprecations? | no | Issues | - | License | MIT I've noticed that the `DumpDataCollector::$webMode` that was added in #52079 was never wired. I'm not sure if this was intentional or an oversight. Commits ------- 7644e9d [DebugBundle] Wire `DumpDataCollector`'s `webMode` argument
Alternative to #51408. I think this approach is simpler and more powerful.
Here, we ensure that the kernel always provides a new
kernel.runtime_modeparameter. This parameter is an array derived by default from theAPP_RUNTIME_MODEenv var, using thequery_stringprocessor.This also creates 3 new parameters that should be the most common:
kernel.runtime_mode.web,kernel.runtime_mode.cli, andkernel.runtime_mode.worker.A long-running server would typically set
APP_RUNTIME_MODEtoweb=1&worker=1orweb=0&worker=1when appropriate (eg https://github.com/php-runtime/frankenphp-symfony/ should do so whenFRANKENPHP_WORKERis set.)I screened the codebase and updated them all except cache pools (where the SAPI is used to enable/disable locking) and error renderers (where the SAPI is used to turn html-rendering on/off.) These require more work that could be done later on. There are a few other remaining usages of
PHP_SAPIbut these look not appropriate for the new flag.