diff --git a/includes/common.inc b/includes/common.inc index cd30145..e641429 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5210,6 +5210,11 @@ function _drupal_bootstrap_full() { unicode_check(); // Undo magic quotes fix_gpc_magic(); + // Reset drupal_alter() and module_implements() static caches as these + // include implementations for vital modules only when called early on + // in the bootstrap. + drupal_static_reset('drupal_alter'); + drupal_static_reset('module_implements'); // Load all enabled modules module_load_all(); // Make sure all stream wrappers are registered. diff --git a/includes/module.inc b/includes/module.inc index 494924f..8b2e324 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -699,6 +699,10 @@ function module_implements($hook, $sort = FALSE, $reset = FALSE) { } $implementations = &$drupal_static_fast['implementations']; + if (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || (MAINTENANCE_MODE != 'update' && MAINTENANCE_MODE != 'install'))) { + trigger_error('module_implements() should not be called before full bootstrap.', E_USER_WARNING); + } + // We maintain a persistent cache of hook implementations in addition to the // static cache to avoid looping through every module and every hook on each // request. Benchmarks show that the benefit of this caching outweighs the