Modules not loaded when they ought to be loaded in \Drupal\Core\Extension\ModuleHandler::buildHookInfo

Created on 12 March 2013, over 12 years ago
Updated 8 June 2025, 16 days ago

Spinning this issue off from: #1806334-185: Replace the node listing at /node with a view

Problem/Motivation

  • Modules are suddenly not loaded when they ought to be loaded.

In #1806334: Replace the node listing at /node with a view an additional reloading of modules got added to \Drupal\Core\Extension\ModuleHandler::buildHookInfo

    // Make sure that the modules are loaded before checking.
    $this->reload();

It was and is unclear why this is needed.

Proposed resolution

Find the root cause of why $this->reload(); is needed here and fix that and remove this call.
Or find the root cause of why $this->reload(); is needed and document it at this call.

Remaining tasks

  • discuss cause and proposed resolution

User interface changes

  • No UI changes anticipated.

API changes

  • TBD

Related Issues

Originally reported

#1806334-185: Replace the node listing at /node with a view @sun

+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -234,6 +234,8 @@ public function getHookInfo() {
+    // Make sure that the modules are loaded before checking.
+    $this->reload();

It does not really look like we got to the bottom of why modules are suddenly not loaded when they ought to be loaded.

I additionally do not understand why this calls into reload() instead of loadAll().

We definitely need to change this into loadAll(), and we should also figure out why this is suddenly necessary, as it should not be necessary — instead, there's likely a race condition or bogus/incomplete procedure elsewhere in the code that needs to be fixed.

#1806334-188: Replace the node listing at /node with a view @rootatwc

Actually loadAll() wont work, because $this->loaded is TRUE..
This is not a problem when using module_enable() because it explicitly calls load() on the new enabled module:
So if you manually update the moduleList somewhere in your code, you *must* call load or reload methods if you want the new hooks from this module to be available..

#1806334-191: Replace the node listing at /node with a view @sun

1) the problem only exists in the installer

📌 Task
Status

Needs work

Version

11.0 🔥

Component

extension system

Created by

🇺🇸United States stpaultim

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024