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 @@ -138,22 +138,6 @@ protected $themeManager; /** - * User function names grouped by the word before the first underscore. - * - * @var string[] - */ - protected $groupedFunctions = []; - - /** - * All user-defined functions that have been added to groupedFunctions. - * - * The array keys are the function names, for faster dereferencing. - * - * @var bool[] - */ - protected $seenFunctions = []; - - /** * Constructs a \Drupal\Core\Theme\Registry object. * * @param string $root @@ -751,23 +735,14 @@ public function getPrefixGroupedUserFunctions() { $functions = get_defined_functions(); + $grouped_functions = []; // Splitting user defined functions into groups by the first prefix. foreach ($functions['user'] as $function) { - if (isset($this->seenFunctions[$function])) { - continue; - } list($first_prefix,) = explode('_', $function, 2); - $this->groupedFunctions[$first_prefix][] = $function; - } - - // The theme registry may load new code. On encountering newly defined - // functions, we save the list of defined functions again. This works - // because functions cannot disappear between calls. - if (isset($first_prefix)) { - $this->seenFunctions = array_fill_keys($functions['user'], TRUE); + $grouped_functions[$first_prefix][] = $function; } - return $this->groupedFunctions; + return $grouped_functions; } /** only in patch2: unchanged: --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -99,10 +99,12 @@ * before the template file is invoked to modify the variables that are passed * to the template. These make up the "preprocessing" phase, and are executed * (if they exist), in the following order (note that in the following list, - * HOOK indicates the theme hook name, MODULE indicates a module name, THEME - * indicates a theme name, and ENGINE indicates a theme engine name). Modules, - * themes, and theme engines can provide these functions to modify how the - * data is preprocessed, before it is passed to the theme template: + * HOOK indicates the hook being called or a less specific hook. For example, if + * '#theme' => 'node__article' is called, hook is node__article and node. MODULE + * indicates a module name, THEME indicates a theme name, and ENGINE indicates a + * theme engine name). Modules, themes, and theme engines can provide these + * functions to modify how the data is preprocessed, before it is passed to the + * theme template: * - template_preprocess(&$variables, $hook): Creates a default set of variables * for all theme hooks with template implementations. Provided by Drupal Core. * - template_preprocess_HOOK(&$variables): Should be implemented by the module