Postponed
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 May 2022 at 08:36 UTC
Updated:
1 Jun 2022 at 10:03 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
daffie commentedThe patch with testing.
Comment #3
geek-merlinTHX for the awesome work daffie!
Code-wise the patch does what it announces and contains a green test that covers both kernel creation paths.
1) Technically this needs a red test-only patch. NW for that.
I can not see (but may overlook sth) why this can not go to 9.x so setting to 9.5.x
This is not a BC breaking change but may want a CR to make people aware of the feature.
Rationale: Is a container parameter the best API for that? Nut sure, but as the information is likely to be needed in early bootstrap phases, it looks reasonable to me.
Comment #4
daffie commentedThe Swoole module does not use the default
index.phpfile that is used by Apache and the NginX web server. In the file is Drupal core started and the user request handled. This is done by the classDrupal\Core\DrupalKernel. Other parameter of this class are $app_root, which holds the webroot directory and $site_path, which holds the relative directory where the settings.php is located. Both are stored as container parameters. That is why I have chosen to store the $asynchronous value is the same manner. You can store it in other ways, only to me this most in line with how Drupal works.Added a change record and a tests only patch which should fail.
@geek-merlin: Thanks for the review!
Comment #6
daffie commentedReuploading the patch from comment #2.
Comment #7
geek-merlinAll from #2 is resolved, test-only patch is red, draft CR lgtm, so rtbc.
Comment #8
alexpottThis does not set this. This is only here to allow for auto-completion. The comment above need to be updated.
Return typehint.
Return type hint.
Let's add a return typehint on new code.
Comment #9
ravi.shankar commentedAddressed points 2, 3, and 4 of comment #8. Still needs work for other points.
Comment #10
andypostThe only blocker is left, patch needs CS clean-up
Comment #11
andypostThe #8.5 makes a lot of sense, technically it's good idea to allow kernel to know better the env it's using but it makes code more fragile
Core already has separate kernels for update/install and very probably ReactPhp will need further modifications to kernel, and not clear how drush/cli trigger op-cache clean-up, maybe it will need another kernel-kind
@daffie there's also
SERVER_SOFTWAREenvironment variable (displayed at status/report) so it could be used to detect swoole/reactphpComment #12
daffie commentedThe loading of the DrupalKernel instance is separate from handling of the user request for Swoole. I have added the Swoole Server instance to the DrupalKernel instance in Swoole. When handling user request I only need to check if the Swoole Server instance is added to the DrupalKernel to know if I am handling a Swoole server instance.
Using a environment variable as @andypost is suggestion is also a great solution for the problem. Thanks for that!
Marking as postponed for now. If for some reason the 2 solutions will not work in the future for some reason, we will still have this issue to reopen.
Thanks to everyone who helped with this issue. It is really appreciated!
Comment #13
geek-merlinGreat discussuion!
Note about
SERVER_SOFTWARE: It is given in the headers when responding to requests. I'd be cautious to re-use it for internal signaling. Think about a site owner that clears the variable to not disclose its content in headers.The other approach, probing a specific service, sounds very clean.