From b7ac66710151bfbb197e653c1d03a43d2ccfcbfa Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 30 Apr 2012 21:31:44 -0700 Subject: Issue #1213536 by David_Rothstein, tim.plunkett, sun, effulgentsia, Yorirou, xjm: Fixed Non-resettable theme_get_registry() cache causes problems for non-interactive installations. --- includes/theme.inc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'includes/theme.inc') diff --git a/includes/theme.inc b/includes/theme.inc index 268795e17..51e1075ca 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -252,7 +252,20 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb * class. */ function theme_get_registry($complete = TRUE) { - static $theme_registry = array(); + // Use the advanced drupal_static() pattern, since this is called very often. + static $drupal_static_fast; + if (!isset($drupal_static_fast)) { + $drupal_static_fast['registry'] = &drupal_static('theme_get_registry'); + } + $theme_registry = &$drupal_static_fast['registry']; + + // Initialize the theme, if this is called early in the bootstrap, or after + // static variables have been reset. + if (!is_array($theme_registry)) { + drupal_theme_initialize(); + $theme_registry = array(); + } + $key = (int) $complete; if (!isset($theme_registry[$key])) { @@ -335,6 +348,7 @@ function _theme_save_registry($theme, $registry) { * to add more theme hooks. */ function drupal_theme_rebuild() { + drupal_static_reset('theme_get_registry'); cache_clear_all('theme_registry', 'cache', TRUE); } @@ -899,8 +913,6 @@ function list_themes($refresh = FALSE) { * @see themeable */ function theme($hook, $variables = array()) { - static $hooks = NULL; - // If called before all modules are loaded, we do not necessarily have a full // theme registry to work with, and therefore cannot process the theme // request properly. See also _theme_load_registry(). @@ -908,10 +920,7 @@ function theme($hook, $variables = array()) { throw new Exception(t('theme() may not be called until all modules are loaded.')); } - if (!isset($hooks)) { - drupal_theme_initialize(); - $hooks = theme_get_registry(FALSE); - } + $hooks = theme_get_registry(FALSE); // If an array of hook candidates were passed, use the first one that has an // implementation. -- cgit v1.2.3