diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index bb89707..cb9fe42 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -490,8 +490,11 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) $info['preprocess functions'] = array(); $prefixes = array(); if ($type == 'module') { - // Default variable preprocessor prefix. - $prefixes[] = 'template'; + // Add template preprocessor only for templates. + if (!isset($info['function'])) { + // Default variable preprocessor prefix. + $prefixes[] = 'template'; + } // 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. diff --git a/core/modules/system/src/Tests/Theme/RegistryTest.php b/core/modules/system/src/Tests/Theme/RegistryTest.php index 8872f10..9960a2c 100644 --- a/core/modules/system/src/Tests/Theme/RegistryTest.php +++ b/core/modules/system/src/Tests/Theme/RegistryTest.php @@ -99,6 +99,11 @@ public function testMultipleSubThemes() { 'template_preprocess', 'test_basetheme_preprocess_theme_test_template_test', ], $preprocess_functions); + + $preprocess_functions = $registry_base_theme->get()['theme_test_function_suggestions']['preprocess functions']; + $this->assertIdentical([ + 'test_basetheme_preprocess_theme_test_function_suggestions', + ], $preprocess_functions); } /** diff --git a/core/modules/system/tests/themes/test_basetheme/test_basetheme.theme b/core/modules/system/tests/themes/test_basetheme/test_basetheme.theme index 739439f..55ee468 100644 --- a/core/modules/system/tests/themes/test_basetheme/test_basetheme.theme +++ b/core/modules/system/tests/themes/test_basetheme/test_basetheme.theme @@ -27,3 +27,9 @@ function test_basetheme_views_post_render(ViewExecutable $view) { */ function test_basetheme_preprocess_theme_test_template_test(&$variables) { } + +/** + * Implements hook_preprocess_HOOK() for theme_test_function_suggestions theme functions. + */ +function test_basetheme_preprocess_theme_test_function_suggestions(&$variables) { +}