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

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

Comments

stpaultim’s picture

Issue summary: View changes

Adding more information from the previous discussion

xjm’s picture

See #1806334-185: Replace the node listing at /node with a view comments #185, #187, #188, and #191. #189 contains a patch in progress. Tagging for a complete issue summary.

dawehner’s picture

Category: task » bug

From my perspective though this is a bug.

ParisLiakos’s picture

I still see the same debug messages when enabling modules, but it seems random so far, so this is definitely not fixed.
I plan to look into this and fix the little hack i did once i find time..also the test i posted over to the other issue fails for me locally:/

ParisLiakos’s picture

Issue summary: View changes

Removed separate topic to create it's own issue.

stpaultim’s picture

Issue summary: View changes

Cleaning it up a bit and adding the issues summary template.

yesct’s picture

Issue summary: View changes

moved the cut and paste

stpaultim’s picture

Issue summary: View changes

Identifying some of the quotes used to describe problem.

stpaultim’s picture

Issue summary: View changes

Cleaning up the summary under guidance of Core Mentor.

stpaultim’s picture

Issue summary: View changes

Making final changes (I hope) under guidance of my Core Mentor.

ParisLiakos’s picture

ok, what happens is, that install_begin_request() calls drupal_maintenance_theme() which get us to _system_rebuild_theme_data which invokes system_theme_info
And modules are not loaded because _drupal_bootstrap_code() has not run yet..

I am not sure what to do here..call loadAll() in _system_rebuild_theme_data()/install_begin_request()? Does not sound good to me..
I thinks we should just replace reload() with loadAll() in getHookInfo() and add $this->loaded = FALSE; in resetImplementations()

ParisLiakos’s picture

Status: Active » Needs review
StatusFileSize
new2.15 KB
new1.93 KB

patch with the proposal above + a phpunit test to confirm..i hope it fails now, cause locally it does

ParisLiakos’s picture

Component: node.module » base system
jibran’s picture

#6: drupal-1940274.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-1940274.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

Some final formatting changes to issues summary.

star-szr’s picture

Issue summary: View changes
Issue tags: +Needs reroll

Tagging for reroll.

sam hermans’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.06 KB

Rerolled against HEAD

dawehner’s picture

+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -211,7 +211,7 @@ public function getHookInfo() {
-    $this->reload();
+    $this->loadAll();

It is certainly not right to force a reload here.

+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php
@@ -43,4 +43,17 @@ public function testLoadInclude() {
+  public function testGetHookInfo() {

We kinda test more than just GetHookInfo but we "testHookInfoWithNewModule" or something like this. It would be cool if the test method would describe exactly what is going on there.

Status: Needs review » Needs work

The last submitted patch, 11: 1940274-11.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
longwave’s picture

Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative
StatusFileSize
new634 bytes

@lendude mentioned this in #bugsmash. The issue stalled years ago with no clear direction, maybe the underlying bug has been fixed since, so let's just remove the reload() and see what breaks today.

Status: Needs review » Needs work

The last submitted patch, 24: 1940274-24.patch, failed testing. View results

lendude’s picture

Title: Modules not loaded when they ought to be loaded » Modules not loaded when they ought to be loaded in \Drupal\Core\Extension\ModuleHandler::buildHookInfo
Issue summary: View changes

Nice one @longwave

Updated the IS and title to make it more clear (to me at least) what the goal here is.

lendude’s picture

Category: Bug report » Task

Discussed this in #bugsmash with @larowlan and we both agree that in the current state this should be a task. Nothing is broken as far as we can currently tell (this might change if we find the root cause here).

quietone’s picture

Version: 9.3.x-dev » 10.0.x-dev
StatusFileSize
new1.29 KB

I decided to investigate this one a bit.

I learned that for each module in the passed in list of module to moduleInstaller::install calls updateKernel(). When the container is rebuilt the injected dependencies are also updated. One of those dependencies is the moduleHandler which has the information on the loadedFiles. When it is updated that data is cleared and thus the state of the ModuleHandler is lost and a reload is needed so hooks are discovered.

IF that is correct then this patch should have less errors. It just adds the reload() to updateKernel().

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nicxvan’s picture

Component: base system » extension system
nicxvan’s picture

Status: Needs work » Closed (outdated)

The whole hook system has since changed.

xjm’s picture

Adjusting saved issue credits according to credit guidelines.