From e105186172a34f4c3ba05af594e34dfa63083b72 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Sat, 10 Oct 2015 11:40:33 -0400 Subject: Issue #496170 by stefan.r, chx, Fabianx, jbrauer, David_Rothstein, roderik, rwohleb, pounard, kenorb, Jose Reyero, joelpittet, catch: module_implements() cache can be polluted by module_invoke_all() being called (in)directly prior to full bootstrap completion --- includes/common.inc | 5 +++++ includes/module.inc | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index ceac115a5..ef71ee8b6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5212,6 +5212,11 @@ function _drupal_bootstrap_full() { fix_gpc_magic(); // Load all enabled modules module_load_all(); + // 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'); // Make sure all stream wrappers are registered. file_get_stream_wrappers(); // Ensure mt_rand is reseeded, to prevent random values from one page load diff --git a/includes/module.inc b/includes/module.inc index 076992ca9..7bf619b47 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -867,6 +867,11 @@ function module_hook_info() { * @see module_implements() */ function module_implements_write_cache() { + // The list of implementations includes vital modules only before full + // bootstrap, so do not write cache if we are not fully bootstrapped yet. + if (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL) { + return; + } $implementations = &drupal_static('module_implements'); if (isset($implementations['#write_cache'])) { unset($implementations['#write_cache']); -- cgit v1.2.3