Objective

  1. CachedModuleHandler is obsolete since #2213357: Use a proper kernel in early installer
  2. The uncached ModuleHandler was only introduced for the early installer environment.
  3. The early installer environment gets memory cache backends injected now.

Proposed solution

  1. Merge the code from CachedModuleHandler into ModuleHandler.
  2. Remove CachedModuleHandler.
  3. Adjust the service definition in core.services.yml accordingly.

Comments

sun’s picture

Assigned: Unassigned » sun
Status: Active » Needs review
StatusFileSize
new19.04 KB
sun’s picture

Title: Remove obsolete CachedModuleHandler » Merge obsolete CachedModuleHandler into ModuleHandler

I guess the issue title is a bit misleading... ;)

Status: Needs review » Needs work

The last submitted patch, 1: module.handler.1.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new22.99 KB
new3.96 KB
  1. Updated UpdateServiceProvider.
  2. Updated PluginTestBase.
  3. Removed senseless ModuleHandlerUnitTest.
  4. Updated DefaultPluginManagerTest.
damiankloip’s picture

+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -56,6 +56,20 @@ class ModuleHandler implements ModuleHandlerInterface {
+   * Cache backend for storing enabled modules.
...
+  protected $bootstrapCache;

@@ -69,19 +83,22 @@ class ModuleHandler implements ModuleHandlerInterface {
+  public function __construct(array $module_list = array(), CacheBackendInterface $bootstrap_cache) {
...
+    $this->bootstrapCache = $bootstrap_cache;

I don't think we need to name this around the cache bin that we are passing in. As far as this object is concerned, this is just a cache bin. I don't think the name in the property is necessary.

sun’s picture

StatusFileSize
new22.99 KB
new4.03 KB

Renamed $bootstrapCache to $cacheBackend.

damiankloip’s picture

Thanks, looks good. Let's wait for the bot. But I think this is ready.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -232,17 +249,31 @@ public function loadInclude($module, $type, $name = NULL) {
+      if ($cache = $this->cacheBackend->get('hook_info')) {
...
+        $this->cacheBackend->set('hook_info', $this->hookInfo);

@@ -264,16 +294,38 @@ public function getImplementations($hook) {
+    $this->cacheBackend->set('module_implements', array());
+    $this->cacheBackend->delete('hook_info');

Did we ever considered to move this two cache entries into one? This could be a task for a followup.

sun’s picture

We already did #1892574: Remove hook_hook_info_alter() — Next step is to remove hook_hook_info() entirely. No longer needed with auto-loadable code.

AFAIK, that has been discussed a few times before, and everyone agreed, but I wasn't able to find an issue...

jibran’s picture

StatusFileSize
new30.21 KB
new9.32 KB
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -264,16 +294,38 @@ public function getImplementations($hook) {
+    // $this->cacheBackend->get() is more or less constant and reduced further when
...
+    // gains when a large number of modules are installed or hooks invoked, since

@@ -450,9 +502,55 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
+        // It is possible that a module removed a hook implementation without the

More then 80 chars.

I was told to DIY so posting a new patch. We are already updating the docs by adding {@inheritdoc} so I went ahead and fixed 80 char limit for whole ModuleHandler.php file. I hope it is not an issue.
This is a doc change so leaving it RTBC.

damiankloip’s picture

Next step is to remove hook_hook_info() entirely. No longer needed with auto-loadable code.

Sorry, views still uses this... views hooks are loaded from MODULE.views.inc or MODULE.views_execution.inc files.

sun’s picture

@jibran: Thank you!

@damiankloip: Created #2233261: Deprecate hook_hook_info groups, mark hook_hook_info() for deletion to properly discuss that further :-)

damiankloip’s picture

Great, thanks @sun!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: module.handler.10.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new30.21 KB

Merged 8.x (simple diff context conflict)

sun’s picture

This clean-up appears to be a soft-blocker for #2206347: Use event system in ModuleHandler, which will help us to untangle some legacy spaghetti in ModuleHandler — would be great to move forward here :-)

damiankloip’s picture

Yes. Would be really good to get this one in!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: module.handler.15.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new30.21 KB

rerolled.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 19: 2231419-19.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new30.21 KB

Merged 8.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: module.handler.22.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new30.13 KB
catch’s picture

24: module.handler.24.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 24: module.handler.24.patch, failed testing.

Jalandhar’s picture

Status: Needs work » Needs review
StatusFileSize
new30.05 KB

Updating with reroll.

Status: Needs review » Needs work

The last submitted patch, 27: drupal8-module_handler-2231419-27.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new29.32 KB
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

module.handler.29.patch no longer applies.

error: patch failed: core/lib/Drupal/Core/Extension/CachedModuleHandler.php:1
error: core/lib/Drupal/Core/Extension/CachedModuleHandler.php: patch does not apply

rajendar reddy’s picture

Status: Needs work » Needs review
StatusFileSize
new29.31 KB

Updating patch with reroll.

sun’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Manually merged, verified, and confirmed the re-roll.

  • Commit c8f6ace on 8.x by catch:
    Issue #2231419 by sun, jibran, Rajendar Reddy, Jalandhar, damiankloip:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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