API page: http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...
API page: http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...
hook_boot and hook_init are documented as being equivilent except for caching, but theme initialisation (menu_set_custom_theme and drupal_theme_initialize) is performed after hook_init, but after hook_boot.
This important because it means you can't see what theme you're running when in hook_boot, and you can't do anything that might change the theme in hook_init.
Comment | File | Size | Author |
---|---|---|---|
#4 | drupal-init_and_boot_docx-1513580-4.patch | 1.11 KB | matt2000 |
Comments
Comment #1
jhodgdonI don't see where the documentation says they are equivalent except for caching? But sure, probably they should both say something about whether or not the theme system has been initialized.
Hmm... I see that hook_init() is invoked from _drupal_bootstrap_full(), so I can confirm that the theme system is initialized before it is invoked. But I'm not sure where hook_boot() is invoked. Someone needs to figure that out...
Comment #2
ianthomas_ukSorry, it doesn't explictly say that they are identical, but the documentation is the same for both functions.
I'm not sure how the version field is used, but this applies to 7.x as well as 8.x.
Comment #3
jhodgdonVersions: our policy is that we fix it first in Drupal 8, then backport to Drupal 7, hence the "needs backport" tag, and setting the version to Drupal 8.
Doc: The doc for the two pages is not really identical. The hook_init() doc specifically says it is for non-cached pages only, for instance, and it says it runs after modules are loaded, while hook_boot() says it goes before most modules and includes are loaded.
So I think all we can really do here is to add a note to hook_init() that also says the theme system is initialized, and maybe add something to hook_boot() that says the theme system is not initialized.
Comment #4
matt2000 CreditAttribution: matt2000 commentedHow's this?
Comment #5
jhodgdonThat looks fine to me. Thanks! I'll get it committed soon.
Comment #6
jhodgdonThanks! Committed to both 7.x and 8.x.