Problem/Motivation
After #2208429: Extension System, Part III: ExtensionList, ModuleExtensionList and ProfileExtensionList, we now have a canonical repository for modules in a Drupal installation as well as a list of installed modules in configuration storage via 'core.extension:module' config key.
However, that issue did not remove a duplicate storage of installed modules in ModuleHandler::moduleList(). Now that we have a canonical repository for extensions, the list of installed extensions should be in those, while ModuleHandler may only hold a cached copy for performance reasons.
Proposed Resolution
- Remove the moduleList from
ModuleHandlerand only retain a locally cached copy for performance reasons - Deprecate
ModuleHandler::getModuleList()and replace withModuleExtensionList::getInstalled()
This helps avoid potential inconsistencies in the code and enforces separation of concerns.
API Changes
ModuleHandler::getModuleList() is deprecated. New method in ExtensionList::getInstalled() that allows the list of installed extensions to be obtained as a replacement for ModuleHandler::getModuleList()
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2941155-nr-bot.txt | 10.55 KB | needs-review-queue-bot |
| #18 | 2941155-18.patch | 32.39 KB | pradhumanjain2311 |
Issue fork drupal-2941155
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
Comment #10
andypostinitial attempt, let's see how much is broken
The related
setModuleList()also needs refactoringComment #14
donquixote commentedIt looks like we are confusing the
%container.modules%container parameter and the@extension.list.moduleservice.These have very different purposes.
The ModuleExtensionList is _not_ the "canonical repository" for installed modules.
The %container.modules% parameter is, but it is not a service, so it cannot replace what we have in ModuleHandler.
Also it contains arrays instead of Extension objects - which is actually ok, because the Extension objects from ModuleHandler are never fully initialized with all the properties they would have in ModuleExtensionList.
Comment #15
andypostChild issue is fixed #2926070: Deprecate ModuleHandlerInterface::getName()
Comment #17
andypostNeeds more work in MR
Comment #18
pradhumanjain2311 commentedRe-roll Patch for 11.x.
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #20
nicxvan commentedAfter looking at this and reading #2941155-14: ModuleHandler should not maintain list of installed modules now that ModuleExtensionList exists I think I agree, I'm not sure we want to change this.
If we do there is also a method
getInstalledExtensionNames, that is literally getting the list from module handler.Comment #21
andypostwith PHP 8.4 we can have setters for the property so swapping of moduleList could cause propagation