Hey folks!
I lately tried to get Drupal working with PHP-PM and thought about a little adjust that is absolutely required to get even basic functionality working. That functionality is basically that the HttpKernel/DrupalKernel allows a second request (more than one call against `DrupalKernel::handle`) without crashing.
Currently in the handle method calls always a method called `initializeSettings`, which is only necessary once. This patch basically makes sure, that method is only called once.
This gets the basic php-pm approach alive with Drupal. However, some common things currently don't work perfectly like session handling and css file name generation. I guess it's worth to merge this in, so other people don't stumble over the same when trying to get Drupal working with php-pm. :)
Cheers
Marc
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | 2708827-45.patch | 1.27 KB | _utsavsharma |
| #45 | interdiff_d11.txt | 1.27 KB | _utsavsharma |
| #36 | 2708827-36.patch | 1.27 KB | andypost |
| #36 | interdiff.txt | 856 bytes | andypost |
Comments
Comment #2
larowlanI think we should class this as a task, or failing that - a bug
Will work on a test in the morning
Thanks Marc, for php-pm and for contributing!
Comment #4
dawehnerTo be honest this issue should be more like a meta issue, given that there will be many potential subissues.
One problem which you will probably run into is #2613044: Requests are pushed onto the request stack twice, popped once which will polute your memory.
Comment #5
Crell commentedThere can be a meta issue, sure, but this is one targeted fix. Just targeted fix it.
Drupal coding standards say space before the {, and 2-space indent for the method body.
2 space indent, please.
Do we want to throw an exception here? It seems that the failure case results in the same post-condition as the success case: The kernel is now initialized and usable. Why not just return-early instead of throwing an exception, as the end result is still an acceptable state?
Alternatively... maybe this is a good use case for an assertion?
Comment #7
sinasalek commentedHere is the meta issue #2218651: [meta] Make Drupal compatible with persistent app servers like ReactPHP, PHP-PM, PHPFastCGI, FrankenPHP, Swoole
Comment #8
almaudoh commentedI'm interested in this and I saw a small bug in the initial patch, so instead of a review, here's another patch.
This bit should actually check if the settings are NOT initialized, then initialize.
I also agree with #5, so removed the exception throwing as well and fixed the CS nits.
Comment #10
almaudoh commentedComment #11
soul88Could you please explain, why do we need this check
if we have this one?
I mean, wouldn't it be enough to only check if settings were initialized in the initializeSettings method?
Comment #12
almaudoh commentedGood question, it's just to avoid the extra function call.
Comment #14
dawehnerIf this is checked by
initializeSettingsalready, why do we need to check it upfront as well?Comment #16
Anonymous (not verified) commentedIf this is supposed to help use Drupal with ReactPHP(and similar), shouldn't the initializeSettings() internally key the configuration by active site determined from the request?
Comment #18
alauzon commentedThe patch in #8 does not apply to 8.5.x-dev neither to 8.6.x-dev. Fortunately I could apply that patch manually on 8.6.x-dev and now I would like to publish the new patch. Since the patch cannot apply to 8.6.x-dev I cannot create an interdiff.
I'm new at publishing patches. Can you tell me if I can publish my new patch without an interdiff or else what do I do?
Comment #19
dawehner@alauzon You did well! When you don't do any logic changes you also don't need to post an interdiff. But yeah patches and interdiffs are super weird 2018.
Comment #20
wim leers@dawehner How about , or even ? 😜
Comment #23
andypostIssue still makes sense, moreover reactPHP tagged LTS https://github.com/reactphp/react/releases/tag/v1.0.0
The numbers of running SF with reactPHP beats php-pm and sometimes php-fpm
Comment #24
andypostRe-roll and address #14 (interdiff is bigger then patch) - we use this pattern already in
\Drupal\Core\DrupalKernel::boot()OTOH instead of new property we can check that Settings already initialized (probably
try Settings::getInstance() catch ...or add helper methodComment #26
andypostComment #29
andypostre-roll for 9.2
Comment #31
andypostComment #32
andypostComment #33
swatichouhan012 commentedRe-roll for 9.3
Comment #34
joachim commentedLGTM.
Comment #35
catchCan probably drop 'The state' here.
Is this because it's expensive or because it will fatal? Should also say early return rather than early exit.
Comment #36
andypostIt's expensive but may cause a fatal iirc
Comment #37
joachim commentedComment #38
alexpottI think we need to consider what should occur if Kernel::shutdown() is called. I think in this instance we should not reset it. Looking at the behaviour of ::boot() and how it interacts with $this->sitePath.
Therefore I think we need to document that this will still only occur once regardless of calling ::shutdown. Hmmm actually looking at things what happens if you have code calling \Drupal\Core\DrupalKernel::setSitePath() after a shutdown()? I think this change will break expectations.
Comment #43
andypostComment #44
andypostComment #45
_utsavsharma commentedPatch for 11.x.