Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
module_implements is missing a module enabled check before calling hooks for passed modules
Proposed resolution
add a module->exists check
Remaining tasks
none
User interface changes
none
API changes
none
Comment | File | Size | Author |
---|---|---|---|
#22 | 2244681-22.patch | 2.98 KB | marthinal |
Comments
Comment #1
sunComment #2
neclimdulpatch
Comment #3
neclimdulComment #5
neclimdulum.... ok... re-roll.
Comment #6
dawehnerWriting a test should be rather straightforward.
should be FALSE
Comment #8
sun"Awesome" — those test failures are the same as in #2237831: Allow module services to specify hooks, which means that this fix will resolve the failures of that issue. ;-)
Comment #9
neclimdulI'm not sure what the theme failures are, but several of the failures are because hook_requirements is being called on a module that is not "enabled." More to come.
Comment #10
sunHm. Yeah, this is a lot more hairy than I thought — I completely forgot about
hook_requirements()
and similar straw callbacks that are invoked for extensions that are not installed (yet).Given the analysis below, it looks like we can (temporarily) fix this by making
drupal_check_module()
not call intoModuleHandler::invoke()
, but instead, make it use the identical code as indrupal_check_profile()
.Installer:
drupal_check_profile()
:Update:
update_check_requirements()
:update.php operates on installed/enabled modules only, so this should be fine.
Modules UI:
ModulesListForm::buildModuleList()
:→
drupal_check_module()
:Site note: I also wasn't aware that only the Modules UI page checks requirements, but the API does not. Ouch. (separate issue)
Comment #11
neclimdulYes I agree, this is a special case and should be treated as such. Another possibility might be to make adding and removing modules to the internal list of active modules a little easier. In general that sounds like it would be useful but it sounds more problematic then manually running it for solving this case.
Comment #12
sunComment #14
lostkangaroo CreditAttribution: lostkangaroo commented12: module.implements.12.patch queued for re-testing.
Passes locally
Comment #16
sunLet's see whether merging 8.x helps.
Comment #18
marthinal CreditAttribution: marthinal commentedThe problem in the test view is that we have a ".theme" where we are calling the hooks (views_pre_render and views_post_render) and the theme isn't into the list of modules. I'm thinking a way to avoid this... but yes, locally it fails too.
Comment #19
marthinal CreditAttribution: marthinal commented16: module.implements.16.patch queued for re-testing.
Comment #20
dawehnerIs there a reason why we don't use a unit test here? Basically just install and uninstall needs all that crazyness.
Let's fix that and call the functions directly.
Comment #22
marthinal CreditAttribution: marthinal commented@dawehner I'm not sure what you mean. Anyway, is it possible to check what hooks are called from a theme checking the enabled themes? Maybe is it possible to have the enabled themes into the config yaml?
The patch should fix a couple fails, in this case for the default theme only. And I would like to verify if breaks something... let's try
Comment #24
larowlan22: 2244681-22.patch queued for re-testing.
Comment #26
neclimdulI'm sort of glad this failed. Its failing because DUTB doesn't exist anymore. There's another problem though, this functionality is going to break a good part of the phpunit tests for ModuleHandler because we made an implicit dependency on Config through a call to globals and most of the tests are testing methods that call into implements. Don't have an answer for a good way to solve that just yet.
Comment #33
andypostNow extension lists patches are in so hooks for install/requirements could be properly decoupled
Comment #41
larowlanIs this still an issue?
If so definitely needs rerolling
Comment #44
smustgrave CreditAttribution: smustgrave at Mobomo commentedSince there hasn't been a follow up going to close out for now.
If still an issue please reopen updating issue summary.