diff --git a/includes/theme.inc b/includes/theme.inc index cd65d7d..ab7b198 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -202,7 +202,14 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb } // Initialize all themes and engines. - foreach (array_merge($base_theme, array($theme)) as $current) { + // Make sure we do not load the same theme engine twice. + $theme_init = array(); + foreach (list_themes() as $current) { + $key = $current->owner . ' ' . $current->engine; + if (isset($theme_init[$key])) { + continue; + } + if (isset($current->owner)) { include_once DRUPAL_ROOT . '/' . $current->owner; } @@ -211,6 +218,7 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb call_user_func($current->engine . '_init', $current); } } + $theme_init[$key] = $current; } if (isset($registry_callback)) { @@ -1148,14 +1156,12 @@ function theme($hook, $variables = array()) { // The theme engine may use a different extension and a different renderer. if (isset($info['engine'])) { $theme_engine = $info['engine']; - if ($info['type'] != 'module') { - if (function_exists($theme_engine . '_render_template')) { - $render_function = $theme_engine . '_render_template'; - } - $extension_function = $theme_engine . '_extension'; - if (function_exists($extension_function)) { - $extension = $extension_function(); - } + if (function_exists($theme_engine . '_render_template')) { + $render_function = $theme_engine . '_render_template'; + } + $extension_function = $theme_engine . '_extension'; + if (function_exists($extension_function)) { + $extension = $extension_function(); } }