Use the ModuleHandlerInterface when Hook Event Dispatcher is enabled

Created on 10 February 2023, almost 2 years ago

Problem/Motivation

I'm using drupal/core 9.4.9 and drupal/tmgmt 1.4 and getting a fatal error for PHP 7.4

TypeError: Argument 3 passed to Drupal\tmgmt\JobCheckoutManager::__construct()
must be an instance of Drupal\Core\Extension\ModuleHandler,
instance of Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given,
called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php
on line 262 in Drupal\tmgmt\JobCheckoutManager->__construct()
(line 50 of modules/contrib/tmgmt/src/JobCheckoutManager.php).

Proposed resolution

Use the ModuleHandlerInterface instead of the ModuleHandler concrete implementation, because other modules might decorate this class and it would lead to some fatal error.

For example, with the hook_event_dispatcher module enabled, this patch caused a fatal error : https://www.drupal.org/project/hook_event_dispatcher/issues/3277301

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Core

Created by

🇫🇷France FabienM

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

Comments & Activities

Production build 0.71.5 2024