diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 1966f18..cda6e6b 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -705,20 +705,21 @@ public function destruct() { */ public function getPrefixGroupedUserFunctions() { $functions = get_defined_functions(); - $seen = array_flip($this->seenFunctions); // Splitting user defined functions into groups by the first prefix. foreach ($functions['user'] as $function) { - if (isset($seen[$function])) { + if (isset($this->seenFunctions[$function])) { continue; } list($first_prefix,) = explode('_', $function, 2); $this->groupedFunctions[$first_prefix][] = $function; } - // If there were any unseen functions, update the list of seen ones. + // 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 = $functions['user']; + $this->seenFunctions = array_fill_keys($functions['user'], TRUE); } return $this->groupedFunctions;