Some classes in contrib depend on ModuleHandler class instead of the interface

Created on 9 June 2023, over 1 year ago
Updated 15 December 2023, 9 months ago

Problem/Motivation

Some contrib modules (and probably custom) have classes that depend on the class ModuleHandler, instead of the ModuleHandlerInterface.
This causes problems with hux.

PHP Fatal error: Uncaught TypeError: ***::__construct(): Argument #1 ($module_handler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hux\HuxModuleHandler given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and defined in ***

In most cases, these modules are simply doing it wrong and should be patched to use the interface.
All that we need to do is to tell people what to do.

Steps to reproduce

Proposed resolution

Easiest solution:
Just leave this issue as a place that people will hopefully find if they search the error message.

Second easiest solution:
Add something on the module page or in README.md.

More effort:
Detect services that depend on the ModuleHandler class.
I don't think this is worth it..

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Closed: outdated

Version

1.2

Component

Documentation

Created by

🇩🇪Germany donquixote

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @donquixote
  • Status changed to Closed: outdated 9 months ago
  • 🇦🇺Australia dpi Perth, Australia

    For a while I was keeping a tab on contrib issue queues, listening for these issues and making them all consistent, since I put together the same Hux work for Hook Event Dispatcher.

    You can see many of them referenced by #3277301: Adapt to centralised hook dispatcher in Drupal 9.4 .

    Im sure theres enough google juice at this point, if not for that issue then any of the referenced issues.

Production build 0.71.5 2024