With the container, and the possibility that page caching is going to be replaced by HttpCache, bootstrap hooks don't really have a place any more. They all have some kind of use case, but usually that use case can be handled by some other mechanism.

Opening this meta-issue to track various issues that have already been open for a while, see discussion in those for more details. This one can also handle removing the bootstrap column in the system table, bootstrap_invoke_all() etc.

#1289536: Switch Watchdog to a PSR-3 logging framework
#1860026: Remove hook_exit() for cached page requests
#1911178: Remove hook_exit()
#1833442: Remove hook_boot()
#1899994: Disentangle language initialization from path resolution

Comments

berdir’s picture

This would also allow to remove the page_cache_invoke_hooks variable, which we don't want to convert to CMI I think but can't convert to a setting because we currently can't provide test coverage for settings on page requests as we need a test-writable settings.php for that.

catch’s picture

Also page_cache_without_database - since that only bypassed variable_init() and hook invocation.

Anonymous’s picture

yes please.

plach’s picture

I think hook_language_init() could be easily removed once #1763640: Introduce config context to make original config and different overrides accessible is in.

katbailey’s picture

hook_language_init() was given the boot in #1899994: Disentangle language initialization from path resolution but I forgot to actually remove it from the array of bootstrap hooks in that patch - tiny follow-up that does that is here: #1907700: Remove language_init from the array of bootstrap hooks as it no longer exists

Crell’s picture

Issue summary: View changes

Add second hook_exit issue.

benjifisher’s picture

Title: Get rid of all 'bootstrap' hooks » [META] Get rid of all 'bootstrap' hooks

updating the title

catch’s picture

Status: Active » Needs review
StatusFileSize
new6.51 KB

Watchdog is the only remaining hook. We could consider doing this as an interim step until there's a logging service that doesn't have the module system dependency, errors still get displayed by drupal_set_message() if modules aren't loaded yet.

Status: Needs review » Needs work

The last submitted patch, 1888734.patch, failed testing.

Crell’s picture

I am OK with #7 as a workaround for the time being (once it actually installs). We should still make sure that #1289536: Switch Watchdog to a PSR-3 logging framework happens regardless, though.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new8.19 KB

This one installs, also turns out the hacks weren't needed at all.

catch’s picture

Title: [META] Get rid of all 'bootstrap' hooks » Get rid of all 'bootstrap' hooks
catch’s picture

#1289536: Switch Watchdog to a PSR-3 logging framework just went RTBC but for some reason doesn't contain any of these changes.

ParisLiakos’s picture

Yeah i only made bootstrap_hooks return an empty array, so we kill those stuff here, but i am ok if you want to do this there

katbailey’s picture

It seems Paris wanted to leave these changes out of the watchdog patch - see #1289536-118: Switch Watchdog to a PSR-3 logging framework
Will wait for testbot before RTBCing but this patch is just lovely :)

catch’s picture

I don't think the patches conflict much if at all, so seems fine to have two issues given the code's already written.

Status: Needs review » Needs work

The last submitted patch, 1888734_bootstrap.patch, failed testing.

catch’s picture

OK that's all the upgrade path tests, no time to look at those for a bit but my guess would be the move of module.inc include to DRUPAL_BOOTSTRAP_CODE.

katbailey’s picture

Status: Needs work » Needs review
StatusFileSize
new8.83 KB
new653 bytes

OK, let's try this...

Anonymous’s picture

looks good.

nitpick, there's still a line in the comments for drupal_flush_all_caches() about bootstrap hooks.

Crell’s picture

+++ b/core/includes/bootstrap.inc
@@ -1325,13 +1309,6 @@ function drupal_serve_page_from_cache(stdClass $cache, Response $response, Reque
-function bootstrap_hooks() {
-  return array('watchdog');
-}
-

Just a note this will conflict with the Watchdog patch, so let's make sure that gets in first as this is easier to reroll.

catch’s picture

That's not much of a conflict, and that patch is CNW at the moment.

catch’s picture

#18: 1888734_bootstrap.18.patch queued for re-testing.

ParisLiakos’s picture

yeah, it only conflicts on the bootstrap hooks function, one line conflict, dead easy to resolve..i will probably have time to work on the issue there, this weekend, but i would have no problem at all with this being committed in the meantime

no_angel’s picture

#18: 1888734_bootstrap.18.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1888734_bootstrap.18.patch, failed testing.

no_angel’s picture

First patch re-roll attempt: not able to resolve.

localhost:8.x angelamaunz$ git checkout -b 1888734-bootstrap18 760292ee835
Switched to a new branch '1888734-bootstrap18'

localhost:8.x angelamaunz$ git apply --index 1888734_bootstrap.18.patch
localhost:8.x angelamaunz$ git commit -m "Applying patch from https://drupal.org/node/1888734"
[1888734-bootstrap18 55ca3ac] Applying patch from https://drupal.org/node/1888734
7 files changed, 5 insertions(+), 109 deletions(-)
localhost:8.x angelamaunz$ git rebase 8.x
First, rewinding head to replay your work on top of it...
Applying: Applying patch from https://drupal.org/node/1888734
Using index info to reconstruct a base tree...
M core/includes/bootstrap.inc
M core/includes/common.inc
M core/includes/update.inc
M core/lib/Drupal/Core/Extension/CachedModuleHandler.php
M core/lib/Drupal/Core/Extension/ModuleHandler.php
M core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
M core/modules/system/system.module
Falling back to patching base and 3-way merge...
Auto-merging core/modules/system/system.module
CONFLICT (content): Merge conflict in core/modules/system/system.module
Auto-merging core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
Auto-merging core/lib/Drupal/Core/Extension/ModuleHandler.php
Auto-merging core/lib/Drupal/Core/Extension/CachedModuleHandler.php
Auto-merging core/includes/update.inc
Auto-merging core/includes/common.inc
Auto-merging core/includes/bootstrap.inc
Failed to merge in the changes.
Patch failed at 0001 Applying patch from https://drupal.org/node/1888734
The copy of the patch that failed is found in:
/Users/angelamaunz/Sites/8.x/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

/**
<<<<<<< HEAD
* Refreshes the list of bootstrap modules.
*
* This is called internally by module_enable/disable() to flag modules that
* implement hooks used during bootstrap, such as hook_watchdog(). These modules
* are loaded earlier to invoke the hooks.
*/
function _system_update_bootstrap_status() {
$bootstrap_modules = array();
foreach (bootstrap_hooks() as $hook) {
foreach (Drupal::moduleHandler()->getImplementations($hook) as $module) {
$bootstrap_modules[$module] = drupal_get_filename('module', $module);
}
}
Drupal::state()->set('system.module.bootstrap', $bootstrap_modules);
}

/**
=======
>>>>>>> Applying patch from https://drupal.org/node/1888734

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new8.85 KB

Re-rolled.

chx’s picture

Status: Needs review » Reviewed & tested by the community

So the patch is green. Only watchdog is left and I presume https://drupal.org/node/1289536 could be committed to fix that. The bootstrap mechanism is awkward and chipping away duties from system_rebuild_module_data is a huge win cos we want that function to die a fiery death.

webchick’s picture

Title: Get rid of all 'bootstrap' hooks » Change notice: Get rid of all 'bootstrap' hooks
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

The impact this will presumably have is in modules if you're trying to invoke watchdog() early enough, it won't actually work and will just silently fail. I could see this being nastily surprising to people. However, #1289536: Switch Watchdog to a PSR-3 logging framework seems pretty close, which will address that issue for watchdog specifically, and catch also pointed me to #1905334: Only load all modules when a hook gets invoked which solves it more generally.

Otherwise:

7 files changed, 5 insertions, 109 deletions.

That's a nice diffstat. ;)

Committed and pushed to 8.x. Thanks!

We'll need a change notice for this.

catch’s picture

Title: Change notice: Get rid of all 'bootstrap' hooks » Get rid of all 'bootstrap' hooks
Status: Active » Fixed
Issue tags: -Needs change record

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.