While working on #320331: Turn custom_url_rewrite_inbound and custom_url_rewrite_outbound into hooks and the new authorize.php from #538660: Move update manager upgrade process into new authorize.php file (and make it actually work) Dave Reid and I discovered a very nasty bug in drupal_bootstrap(). :(
Thanks to #497118: Remove the registry (for functions) (presumably by accident, not intentionally), drupal_bootstrap() is needlessly loading all bootstrap modules way too early in the bootstrap -- all the way down at DRUPAL_BOOTSTRAP_VARIABLES. This shouldn't actually happen until DRUPAL_BOOTSTRAP_PAGE_HEADER. Not only is this a critical performance bug, it means that authorize.php is actually loading all modules that invoke hook_boot(), making those dangerous to upgrade via the update manager. :(
Trivial patch coming soon... stay tuned.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | drupal.bootstrap-module-system.12.patch | 6.85 KB | sun |
| #10 | drupal.bootstrap-module-system.10.patch | 5.91 KB | sun |
| #9 | drupal.bootstrap-module-system.9.patch | 5.63 KB | sun |
| #8 | drupal.bootstrap-module-system.8.patch | 4.83 KB | sun |
| #1 | 606146-1.bootstrap_load_modules_when_needed.patch | 1.12 KB | dww |
Comments
Comment #1
dwwComment #2
dave reidSo we do a module_load_all($bootstrap = TRUE) in addition we run drupal_load('module', $module) inside bootstrap_invoke_all('boot'). Maybe we should reduce that down even more?
Comment #4
moshe weitzman commented@Davereid - thats a possiible (minor) optimization, but isn't strictly related to this patch. Anyone available to fix these test failures. Subscribe.
Comment #5
JacobSingh commentedThe tests are not testing any units, but entire page loads, so they don't really help much in terms of tracking down where exactly the problem is. They are all related to a session not being destroyed when being viewed anonymously. Basically, when the dsm() is shown, the session should be getting cleared so that next page load it is empty. This isn't happening.
Any ideas?
Relevant code in sessions.test
Comment #6
JacobSingh commentedInterestingly, the message does not show the second time, but the session also has something in it... what is has in it, we'll never know :)
Comment #7
JacobSingh commentedheh, awesome. Okay in session-test.module:
I'm guessing since we don't call HOOK_BOOT anymore in BOOTSTRAP_SESSION, this header never gets sent so "simple" test never finds out that the fake session is empty. poo.
Where do we fix this test? Do we fix the test? The test is also giving false positives thinking the session is full when it isn't.
I tried moving the header into hook_init, but that didn't seem to work. Don't know the internals of the testing stuff to say why.
Comment #8
sun1) Not sure whether the module system should be bootstrapped after the session only.
2) Clearly, we don't need to bootstrap the module system for variables only.
3) Whatever further optimization we do, it's easier to modify when bootstrapping the module system in its own bootstrap phase.
4) module_load_all(TRUE) and bootstrap_invoke_all('boot') are superfluous and the latter should be used during bootstrap.
5) By doing so, we can also vastly simplify module_load_all(), because it's no longer called with two different purposes.
Comment #9
sunMake even more sense of module_load_all().
Comment #10
sunOf course, that was a bit "blind" ;)
Comment #12
sunStrange. There seems to be some more magic going on here.
Even with this patch, my local Apache completely freezes when trying to run any tests. -- although the bootstrap behavior should be identical...
Comment #13
dries commentedThis seems like a nice clean-up to me, but it would be good to get sign off from dww or Jacob.
Comment #14
JacobSingh commentedI find this comment terribly confusing. If the function is called module_load_all and I can pass $load == FALSE into it, it's kinda non-nonsensical isn't it?
This function really includes the module file right? So maybe the function should be called module_include_all?
Also, I think I'd make the $load variable $refresh. Although it is also a bit confusing, it at least is consistent with the name in module_list().
Otherwise, this looks like it would solve the problem. Nice one!
-J
This review is powered by Dreditor.
Comment #15
damien tournoud commentedThe patch makes sense, but the API changes introduced here do not :)
Erm. No. Let's add a bootstrap_load_all() or something.
Is there really a reason *not to* run the hook_boot() in DRUPAL_BOOTSTRAP_MODULE?
Erm. No.
We need a module_loaded() or something like this.
This review is powered by Dreditor.
Comment #16
moshe weitzman commentedIt is a bit confusing to add a phase called DRUPAL_BOOTSTRAP_MODULE. Could we rename to DRUPAL_BOOTSTRAP_BOOT_MODULES. This distinguishes the phase from the part of FULL where we load all enabled modules.
This patch does not move the loading of boot modules, which was the initial point of this issue. IMO it is a critical regression. We need to move this new phase after SESSION phase just like in D6. It sounds like this breaks some session tests. We need to fix those.
This patch is still commit-worthy though.
Comment #17
sun.core commentedNot critical. Please read and understand Priority levels of Issues, thanks.
Comment #18
fabianx commentedSubscribe.
Comment #19
saravanan82 commented#12: drupal.bootstrap-module-system.12.patch queued for re-testing.
Comment #21
sunThis proposal has been replaced by DRUPAL_BOOTSTRAP_CODE in D8, which has since been moved into the new bootstrap logic in
DrupalKernel.D7 bootstrap is very unlikely to be changed at this point.
Comment #22
mikeytown2 commentedHeads up that if you put this
$conf['page_cache_invoke_hooks'] = FALSE;in your settings.php file the sessions test fails.