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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7

I 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...

ianthomas_uk’s picture

Sorry, 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.

jhodgdon’s picture

Title: hook_init and hook_boot documentation ignores theme initialisation » hook_init and hook_boot documentation should say whether themes are initialized
Issue tags: +Novice

Versions: 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.

matt2000’s picture

Status: Active » Needs review
FileSize
1.11 KB

How's this?

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

That looks fine to me. Thanks! I'll get it committed soon.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Committed to both 7.x and 8.x.

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