diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-30 21:31:44 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-30 21:31:44 -0700 |
commit | b7ac66710151bfbb197e653c1d03a43d2ccfcbfa (patch) | |
tree | c85164d8dc84c1e78a65f4841f7b928767a0c4c0 /includes/theme.inc | |
parent | d0b5d31cbca7b5ce521ee180b6ca31e301b63b4e (diff) | |
download | brdo-b7ac66710151bfbb197e653c1d03a43d2ccfcbfa.tar.gz brdo-b7ac66710151bfbb197e653c1d03a43d2ccfcbfa.tar.bz2 |
Issue #1213536 by David_Rothstein, tim.plunkett, sun, effulgentsia, Yorirou, xjm: Fixed Non-resettable theme_get_registry() cache causes problems for non-interactive installations.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 23 |
1 files changed, 16 insertions, 7 deletions
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. |