diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 364e0aa..d0ef571 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -10,6 +10,7 @@ use Drupal\Component\Graph\Graph; use Drupal\Component\Serialization\Yaml; use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\Core\Cache\CacheBackendInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -579,15 +580,10 @@ protected function buildImplementationInfo($hook) { if ($group) { $this->loadInclude($module, 'inc', "$module.$group"); } - // It is possible that a module removed a hook implementation without - // the implementations cache being rebuilt yet, so we check whether the - // function exists on each request to avoid undefined function errors. - // Since ModuleHandler::implementsHook() may needlessly try to - // load the include file again, function_exists() is used directly here. + // If a new implementation was added, verify that the function exists. if (!function_exists($module . '_' . $hook)) { - // Clear out the stale implementation from the cache and force a cache - // refresh to forget about no longer existing hook implementations. - unset($implementations[$module]); + $function = String::checkPlain($module . '_' . $hook); + throw new \Exception("An invalid implementation '$function' was added by hook_module_implements_alter()"); } } }