Closed (fixed)
Project:
Drupal core
Version:
main
Component:
extension system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Feb 2026 at 15:41 UTC
Updated:
19 Mar 2026 at 02:55 UTC
Jump to comment: Most recent
hook_module_implements_alter was slated for removal in 12, let's remove it and all support.
N/A
Remove hook_module_implements_alter support and documentation.
Review
N/A
N/A
N/A
N/A
N/A
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 #2
nicxvan commentedComment #4
nicxvan commentedI will continue to work on this
Comment #5
nicxvan commentedComment #6
nicxvan commentedLet's invert these postponements since this one has a lot more failures.
Comment #7
nicxvan commentedComment #8
nicxvan commentedComment #9
smustgrave commentedSeems blocker has just landed.
Comment #10
nicxvan commentedJust confirming that I want this still assigned to me.
I will review.
Comment #14
nicxvan commentedI tracked down all of the other changes.
one was due to an over aggressive cleanup which I restored.
The only mystery is why Form/Functional/AlterTest.php changed https://git.drupalcode.org/project/drupal/-/merge_requests/14784/diffs#e...
I think it might be because it's defined with the module key instead of directly in the module:
#[Hook('form_form_test_alter_form_alter', module: 'block')]I suspect that we want to fix this, but it's not immediately clear where this is changing.
Edit: on further inspection there are more failures now because now
$implementationsByHook[$hook] is empty since
doesn't populate since block is not installed, but I can't see how not having
changes this.
Comment #16
berdirA few kernel tests have a type error, that seems to be because \Drupal\common_test\Hook\CommonTestHooks::blockDrupalAlterFooAlter implements a hook for block module and also sets the order of it but then that module isn't enabled in those tests and it's confused about that. Related to #3536470: TypeError if #[ReOrderHook] targets hook that has no implementations anywhere in enabled modules. but that is fixed, so I guess it's a different case. Added a check for that, not entirely sure that's the correct fix.
Also noticed that in \Drupal\Core\Hook\HookCollectorPass::calculateImplementations(), the removed hook is still mentioned.
Started looking into AlterTest, but need to get up to speed on how this order stuff works, didn't really work with it yet.
Comment #17
nicxvan commentedYeah I found that too, the piece I couldn't figure out was why it didn't blow up before pulling the procedural call.
For alter they are all defined in the same module two are on behalf of other modules though (system and block)
This combined with the other failures makes me think it's an issue around defining hooks on behalf of other modules.
I wonder if we should deprecate that long term since a module exists check works and we have the other conditional issue we're working on.
Comment #18
nicxvan commentedOk I think I confirmed it's a side effect of implementing on behalf of others.
I set the order parameter on that hook.
I wonder if we should just add a CR to this that if you're relying on the 'module' parameter that you may need to evaluate order.
That is a BC compatible change since
#[Hook('form_form_test_alter_form_alter', module: 'block', order: Order::First)]would have done nothing before this issue since it was already first, adding it here moves it back to first.BTW before 14 I did checkout main and compared
calculateImplementationsbefore and after with multiple variations.I didn't see anything obvious that was changing. Now that we've identified how it's changing and it's a rare edge case I think we want to deprecate anyway, AND has a fairly simple workaround if it's even an issue. I think this might be ready beyond wanting to properly fix the order bit.
Extra notes, as I was writing this I reread the issue you mentioned and realized the issue. I fixed it here is the reasoning.
I think the real fix is
if (!isset($implementationsByHook[$hook][$operation->identify()])) {needs to also check if the module is enabled, then we need to filter for empty order sets at the end, it's just a couple of lines so I added that but should be reviewed.Comment #19
nicxvan commentedLeaving this assigned to me for now for addressing any feedback that comes up, but I think this is ready for review.
Comment #20
nicxvan commentedGotta fix the missing type error failures too.
Comment #21
nicxvan commentedI found the side effect changing the order of the implemented on behalf of other modules:
The
reOrderModulesForAltermethod reset order to module order first before reapplying the order.This only affects alters, I'm not sure we want to preserve or remove this now.
Adding the following back fixes the tests without needing to add a new order directive so this preserves current behavior so I'd vote for keeping it in.
Comment #22
nicxvan commentedThis is finally ready for review!
Comment #23
smustgrave commentedProbably best if berdir reviewed this one but anything I can do to help test
Comment #24
berdirPosted a review that I had already started a few days ago.
Comment #25
nicxvan commentedI addressed some of your feedback and replied to the rest.
Comment #26
berdirI think the deprecation cleanup here is fine.
I have some thoughts/concerns on how orders/module weights work and I suspect there are some gaps/unexpected behaviors, but that's not related to hook_module_implements_alter().
So long hook_module_implements_alter(), and thanks for all the headaches.
Comment #27
catchRIP one of the most evil yet simultaneously useful hooks.
Committed/pushed to main, thanks!
Comment #31
nicxvan commentedFor posterity where it was introduced #692950-1: Use hook_module_implements_alter to allow modules to alter the weight of hooks in module_implements
Thanks!
Comment #32
nicxvan commented