diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index c19fd4d..de9ca4a 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -507,12 +507,14 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) $prefixes = array(); if ($type == 'module') { - // Default variable preprocessor prefix. - $prefixes[] = 'template'; + // Modules may implement the default preprocessor of a hook. + if (function_exists('template_preprocess_' . $hook)) { + $info['preprocess functions'][] = 'template_preprocess_' . $hook; + } // Add all modules so they can intervene with their own variable // preprocessors. This allows them to provide variable preprocessors // even if they are not the owner of the current hook. - $prefixes = array_merge($prefixes, $module_list); + $prefixes = $module_list; } elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { // Theme engines get an extra set that come before the normally diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index ea764a7..342eec0 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -288,11 +288,13 @@ public function render($hook, array $variables) { } } - // Set default variables before preprocess hooks. - $this->addDefaultTemplateVariables($variables); - $render_element_type = isset($info['render element']) ? $info['render element'] : NULL; - $this->addElementAttributeVariables($variables, $render_element_type); - + // Don't add template variables for hooks implemented as functions. + if (!isset($info['function'])) { + // Set default variables before preprocess hooks. + $this->addDefaultTemplateVariables($variables); + $render_element_type = isset($info['render element']) ? $info['render element'] : NULL; + $this->addElementAttributeVariables($variables, $render_element_type); + } // Invoke preprocess hooks. // By default $info['preprocess functions'] should always be set, but it's // good to check it if default Registry service implementation is