Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Add parameterskernel.runtime_mode andkernel.runtime_mode.*, all set from env varAPP_RUNTIME_MODE#52079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.4fromnicolas-grekas:hk-runtime_mode
Oct 20, 2023

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedOct 16, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#51340
LicenseMIT
Doc PRTODO

Alternative to#51408. I think this approach is simpler and more powerful.

Here, we ensure that the kernel always provides a newkernel.runtime_mode parameter. This parameter is an array derived by default from theAPP_RUNTIME_MODE env var, using thequery_string processor.

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 setAPP_RUNTIME_MODE toweb=1&worker=1 orweb=0&worker=1 when appropriate (eghttps://github.com/php-runtime/frankenphp-symfony/ should do so whenFRANKENPHP_WORKER is 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 ofPHP_SAPI but these look not appropriate for the new flag.

@carsonbotcarsonbot added this to the6.4 milestoneOct 16, 2023
@nicolas-grekasnicolas-grekas added the ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" labelOct 16, 2023
@nicolas-grekasnicolas-grekasforce-pushed thehk-runtime_mode branch 2 times, most recently from5e777ad to1387951CompareOctober 16, 2023 20:18
@stof
Copy link
Member

shouldn't the error rendering depend on web_mode ? For a long-running server, we would want to provide the web error rendering.

dunglas reacted with thumbs up emoji

@nicolas-grekas
Copy link
MemberAuthor

shouldn't the error rendering depend on web_mode

yes, but it's too much work for me for now, could be handled later on (same for cache locking, see PR description)

dunglas reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas changed the title[HttpKernel] Add parameterkernel.runtime_mode, defined as%env(default:container.runtime_mode:APP_RUNTIME_MODE)%[HttpKernel] Add parameterskernel.runtime_mode andkernel.runtime_mode.*, all set from env varAPP_RUNTIME_MODEOct 18, 2023
@nicolas-grekas
Copy link
MemberAuthor

PR updated. No special service anymore, only parameters. Here is the new description:

Here, we ensure that the kernel always provides a newkernel.runtime_mode parameter. This parameter is an array derived by default from theAPP_RUNTIME_MODE env var, using thequery_string processor.

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 setAPP_RUNTIME_MODE toweb=1&worker=1 orweb=0&worker=1 when appropriate (eghttps://github.com/php-runtime/frankenphp-symfony/ should do so whenFRANKENPHP_WORKER is set.)

dunglas reacted with thumbs up emoji

}

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)) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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])) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this change allows to derivate dynamic parameters from other ones, eg%env(key:foo:default:bar:)% extracts keyfoo from parameterbar (which is supposed to be an array here)

…_mode.*`, all set from env var `APP_RUNTIME_MODE`
}elseif (\function_exists('litespeed_finish_request') && !$this->debug) {
litespeed_finish_request();
}else {
Response::closeOutputBuffers(0,true);
Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasOct 18, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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.

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitb6418aa intosymfony:6.4Oct 20, 2023
@nicolas-grekasnicolas-grekas deleted the hk-runtime_mode branchOctober 20, 2023 17:08
This was referencedOct 21, 2023
alexander-schranz pushed a commit to php-runtime/runtime that referenced this pull requestOct 30, 2023
Nyholm pushed a commit to php-runtime/frankenphp-symfony that referenced this pull requestOct 30, 2023
nicolas-grekas added a commit that referenced this pull requestOct 12, 2025
…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       | MITI'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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

@welcoMatticwelcoMatticAwaiting requested review from welcoMatticwelcoMattic is a code owner

Assignees

No one assigned

Labels

FeatureHttpKernel❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze"Status: Reviewed

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

Function to check if the kernel is loaded via the console or a web request.

5 participants

@nicolas-grekas@stof@fabpot@dunglas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp