Removing a Hux hook implementation/class can cause fatal errors

Created on 8 August 2022, almost 2 years ago
Updated 16 December 2023, 6 months ago

Problem/Motivation

I deployed some hook refactors into Hux classes and then had to revert the PR. Upon deploying the revert I get this error (including most of the stacktrace incase it helps us track down the issue):

Steps to reproduce

  1. Ensure hux optimize mode is turned on in services.yml
  2. Add a Hooks class that defines a low level hook such as #[Alter('views_data')]
  3. Hit your site to prime the hux cache
  4. Change the name of the function for the hook defined above
  5. Run drush cr
  6. See an error similar to below.
./bin/drush -r /data/app deploy -y
 [notice] Database updates start.
>  [success] No pending updates.
 [success] Cache rebuild start.
> PHP Fatal error:  Uncaught TypeError: Failed to create closure from callable: class Drupal\snsw_content_personalisation\Hooks\SnswContentPersonalisationHooks does not have a method "entityTypeAlter" in /data/app/modules/contrib/hux/src/HuxModuleHandler.php:269
> Stack trace:
> #0 /data/app/modules/contrib/hux/src/HuxModuleHandler.php(269): Closure::fromCallable()
> #1 /data/app/modules/contrib/hux/src/HuxModuleHandler.php(157): Drupal\hux\HuxModuleHandler->generateAlterInvokers()
> #2 /data/app/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(334): Drupal\hux\HuxModuleHandler->alter()
> #3 /data/app/core/lib/Drupal/Core/Entity/EntityTypeManager.php(123): Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions()
> #4 /data/app/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\Core\Entity\EntityTypeManager->findDefinitions()
> #5 /data/app/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
> #6 /data/app/core/lib/Drupal/Core/Entity/EntityTypeManager.php(132): Drupal\Core\Plugin\DefaultPluginManager->getDefinition()
> #7 /data/app/core/lib/Drupal/Core/Entity/EntityTypeManager.php(253): Drupal\Core\Entity\EntityTypeManager->getDefinition()
> #8 /data/app/core/lib/Drupal/Core/Entity/EntityTypeManager.php(192): Drupal\Core\Entity\EntityTypeManager->getHandler()
> #9 /data/app/core/lib/Drupal/Core/Datetime/DateFormatter.php(93): Drupal\Core\Entity\EntityTypeManager->getStorage()
> #10 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\Core\Datetime\DateFormatter->__construct()
> #11 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService()
> #12 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get()
> #13 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(240): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters()
> #14 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService()
> #15 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get()
> #16 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(276): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters()
> #17 /data/app/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService()
> #18 /data/app/core/lib/Drupal.php(197): Drupal\Component\DependencyInjection\Container->get()
> #19 /data/app/core/includes/common.inc(559): Drupal::service()
> #20 /data/app/core/includes/utility.inc(41): drupal_flush_all_caches()
🐛 Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

🇦🇺Australia acbramley

Live updates comments and jobs are added and updated live.

Missing content requested by

🇦🇺Australia dpi
7 months ago
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024