Problem/Motivation

Use Dependency Injection to provide the appropriate object to the Service.

Steps to reproduce

Install this module Hook Events Dispatcher

An error is thrown when the content is using Lazy Load module:

See log file attached "Lazy_Hook_Event_Dispatcher_issue.txt"

Proposed resolution

Replace Class moduleHandler with its Interface moduleHandlerInterface.

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork lazy-3308141

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rodetrev created an issue. See original summary.

rodetrev’s picture

DieterHolvoet made their first commit to this issue’s fork.

dieterholvoet’s picture

Status: Active » Needs review

I pushed a fix to the MR. Without this fix, sites running the latest version of Hook Event Dispatcher are completely broken.

dpi’s picture

Many people are seeing errors related to ModuleHandler as a result of upgrading Hook Event Dispatcher, which includes a module handler service decorator.

Projects need to ensure interfaces are used while injecting services, so this project will need to make the code change here.

dpi’s picture

Title: Use interfaces in Lazy service » Lazy should typehint ModuleHandler interface rather than a specific implementation
dieterholvoet’s picture

Any update? This is breaking sites left and right.

rhip’s picture

StatusFileSize
new1.49 KB

Uploading a diff file of the patch created in the Issue Fork (for security reasons).

dieterholvoet’s picture

blainelang’s picture

WSOD after updating from 9.4.8 to 9.5
"NOTICE: PHP message: TypeError: Drupal\lazy\Lazy::__construct(): Argument #5 ($module_handler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 263 in /var/www/html/web/modules/composer/lazy/src/Lazy.php on line 67 #0 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(263): Drupal\lazy\Lazy->__construct(Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Http\RequestStack), Object(Drupal\Core\Condition\ConditionManager), Object(Drupal\Core\Routing\AdminContext), Object(Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler))"
Was able to create a patch and apply using composer - thanks @rodetrev

Would be nice to see this rolled into an update.

kaloyan.damyanov’s picture

+1

  • osman committed 4fbb2e21 on 8.x-3.x authored by rodetrev
    Issue #3308141 by rodetrev, DieterHolvoet, RhiP, kaloyan.damyanov: Lazy...
dieterholvoet’s picture

@osman any chance you can create a new release with this and Drupal 10 support? Also, don't forget to mark this issue as Fixed.

leolandotan’s picture

I have tested this with the patch in #12 on Drupal core 9.4.12 and Lazy-load 8.3.11. The error causing the WSOD is now gone.

blainelang’s picture

Should we close this issue if the patch has already been committed and version 3.12.0 released?

dieterholvoet’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.