Updated: Comment #N
Problem/Motivation
DrupalKernel contains code that attempts to support multiple webservers for the same site, by detecting module changes and rebuilding the container if it changed.
That code a) only supports a very limited set of possible situations where this could happen (like pushing new code with different services or adding a language) and b) Affects performance for all the sites that don't use multiple webservers for no reason.
Proposed resolution
Remove it.
We have ideas to solve this problem in a better way, like comparing a flag in the database and one in a file and rebuild on mismatch. This can be done outside of core, optionally, to avoid the overhead for sites that don't need it.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff.txt | 1.3 KB | znerol |
#21 | 2228215-remove-module-check-mini-21.diff | 7.38 KB | znerol |
#17 | interdiff.txt | 2.43 KB | znerol |
#17 | 2228215-remove-module-check-mini-17.diff | 7.36 KB | znerol |
#16 | interdiff.txt | 860 bytes | znerol |
Comments
Comment #1
BerdirHere's the patch. Installer worked.
Comment #2
catchYes this should be something you can opt-in to for sites that want the fail safe - and there's other ways to accomplish it (like timestamp comparison) than loading the configuration every request.
We already rebuild the container on switches to/from multi-lingual and based on settings.php changes, and this doesn't cover either of those, so it's a false sense of security.
Comment #3
sunWhy do we still need this?
Comment #4
BerdirBecause otherwise the module namespaces aren't registered, ever :)
I first removed that, but it completely falls apart :)
Comment #6
znerol CreditAttribution: znerol commentedReroll.
Comment #7
znerol CreditAttribution: znerol commentedJust an idea: Use two separate flags
allowDumping
andallowLoading
. Forcibly set the latter toFALSE
from withinupdateModules
. If we already know that the container on disk is out of date, do not bother trying to load it...Comment #9
catchComment #10
znerol CreditAttribution: znerol commentedNow that the module-list is not checked anymore during the bootstrap, it is essential that the container is dumped each time it is modified in the simpletest parent site. Therefore we need to prevent
WebTestBase::rebuildContainer()
from creating a kernel without$allowDumping
, or even better remove that method entirely (as per #2033567: Remove TestBase::rebuildContainer()).Comment #11
znerol CreditAttribution: znerol commentedComment #14
znerol CreditAttribution: znerol commentedLet's not attack #2033567: Remove TestBase::rebuildContainer() and instead try to keep the changes small. Interdiff is against #6 (the reroll of the original patch).
Comment #16
znerol CreditAttribution: znerol commentedReintroduce the idea that after
DrupalKernel::updateModules()
, the container never ever should be loaded from disk anymore during subsequent rebuilds of the kernel. This also leads to the container being dumped (if dumping is enabled) after eachDrupalKernel::updateModules()
.Comment #17
znerol CreditAttribution: znerol commentedFix
DrupalKernelTest
.Comment #19
sunI'm glad that you removed the changes related to #2033567: Remove TestBase::rebuildContainer(), because I strongly disagree with the idea of removing it. — Instead, what we need is an enhancement to
PhpStorage
that allows it to work in a "single hashed file mode"; i.e., the class name of the dumped file gets a hash appended, which in turn would enable us to actually reload the already dumped container of the test child site from disk (which we cannot do right now, since the class name of the service container is always identical, and PHP does not support to unload code, sorebuildContainer()
intends to just reload, but actually has to rebuild, because the class is loaded already).Aside from that remark, this looks good to me.
As a directly related follow-up, we should get back to #2160091: drupal_rebuild() rebuilds container twice, since drupal_flush_all_caches() also rebuilds it
Lastly, not sure what the consequences of this patch are with regard to #1897468: Kernel rebuilds service container on every request when a module vanishes
Comment #20
catchCouple of comment issues, otherwise looks great.
'to prevent the kernel attempting to read the dependency injection container from disk'?
Are we dumping the kernel or the container?
Comment #21
znerol CreditAttribution: znerol commentedComment #22
sunThanks!
Comment #23
catchCommitted/pushed to 8.x, thanks!
Comment #25
alexpottThe original commit contained #2259275: Rename "DrupalUnitTestBase" to KernelTestBase so I reverted and recommitted see 486e276 (the revert) and 3cc312e (the proper commit)
Comment #27
znerol CreditAttribution: znerol commentedWe should remove even more stuff from
initializeContainer()
: #2277445: Remove newModuleList instance variable from DrupalKernel and related check in initializeContainer