summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 13:17:16 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 13:17:16 -0700
commit5e8f5fbd2fa670126c7e1b39a563439e9b37b136 (patch)
tree54a4917fbce94f88299985375c4d493d1ced815f /includes/theme.inc
parent23efccf4598362d1328f9281d772b0cac0de6735 (diff)
downloadbrdo-5e8f5fbd2fa670126c7e1b39a563439e9b37b136.tar.gz
brdo-5e8f5fbd2fa670126c7e1b39a563439e9b37b136.tar.bz2
Issue #1177738 by catch: Speed up theme registry rebuilds when multiple themes are enabled.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc19
1 files changed, 15 insertions, 4 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 49865cfe0..15651460d 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -512,7 +512,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
}
/**
- * Rebuild the theme registry cache.
+ * Build the theme registry cache.
*
* @param $theme
* The loaded $theme object as returned by list_themes().
@@ -525,9 +525,20 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
function _theme_build_registry($theme, $base_theme, $theme_engine) {
$cache = array();
// First, process the theme hooks advertised by modules. This will
- // serve as the basic registry.
- foreach (module_implements('theme') as $module) {
- _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
+ // serve as the basic registry. Since the list of enabled modules is the same
+ // regardless of the theme used, this is cached in its own entry to save
+ // building it for every theme.
+ if ($cached = cache_get('theme_registry:build:modules')) {
+ $cache = $cached->data;
+ }
+ else {
+ foreach (module_implements('theme') as $module) {
+ _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
+ }
+ // Only cache this registry if all modules are loaded.
+ if (module_load_all(NULL)) {
+ cache_set('theme_registry:build:modules', $cache);
+ }
}
// Process each base theme.