diff -u b/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php --- b/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -570,10 +570,7 @@ * Current active theme. */ protected function postProcessExtension(array &$cache, $theme) { - - // Get all user defined functions. - list(, $user_func) = array_values(get_defined_functions()); - $user_func = array_combine($user_func, $user_func); + $grouped_functions = drupal_group_functions_by_prefix(); // Gather prefixes. This will be used to limit the found functions to the // expected naming conventions. @@ -593,7 +590,11 @@ // Collect all variable processor functions in the correct order. $processors = []; foreach ($prefixes as $prefix) { - $processors += preg_grep("/^{$prefix}_preprocess_($hooks)(__)?/", $user_func); + // Grep only the functions which are within the prefix group. + list($first_prefix,) = explode('_', $prefix, 2); + if (isset($grouped_functions[$first_prefix])) { + $processors += preg_grep("/^{$prefix}_preprocess_($hooks)(__)?/", $grouped_functions[$first_prefix]); + } } // Add missing variable processors. This is needed for hooks that do not