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.
hook_hook_info_alter(), really?
Is anyone able to make up a braindead use-case for that? :)
Comment | File | Size | Author |
---|---|---|---|
#3 | drupal8.hook-hook-info-alter.3.patch | 1.51 KB | sun |
Comments
Comment #1
Dave ReidYes, I've used it to provide support for existing core hooks since two of the same keys causes an array merge of invalid data.
EDIT: That way if core adds support for those hooks, my custom code doesn't cause hooks to break.
http://drupalcontrib.org/api/drupal/contributions%21file_entity%21file_e...
Comment #2
sunI guess you're referring to the behavior of
array_merge_recursive()
?I think that should be resolved by now, since we're using
NestedArray::mergeDeep()
for the information gathered by info hooks now?Can you confirm? If not, that might translate this issue to won't fix (I hope not).
Comment #3
sunHere's a patch.
Comment #4
sunI'm fairly sure that the usage of
NestedArray::mergeDeep()
in HEAD eliminates the need for usinghook_hook_info_alter()
for cases like #1.So how about this:
Comment #5
Crell CreditAttribution: Crell commented+1 to #4.
Comment #6
catchWorks for me as well.
Comment #7
sunComment #8
chx CreditAttribution: chx commentedGiven that Dave had a problem -- does this work for you?
Comment #9
Dave ReidIt appears that module_hook_info() for Drupal 8 still uses array_merge_recursive. That would need to be fixed along with this patch before it could be committed. Would be good to actually have a test that confirms two duplicate entries in hook_hook_info() don't cause things to explode since it's not as typically of a hook invocation as usual.
Comment #10
Dave ReidWait a sec, appears I'm a victim of api.drupal.org being very out of date. Attempting to confirm locally.
Comment #11
Dave ReidOk had a chance to completely reset a very screwed up and broken D8 sandbox and pull the current code. I confirmed that duplicate hook_info() results are in fact merged properly.
I did run into a WTF with ModuleHandler: #1899514: ModuleHandlerInterface::getHookInfo should not be protected.
Comment #12
catchCommitted/pushed to 8.x. We should add a change notice.
Comment #13
Crell CreditAttribution: Crell commentedChange notice added: http://drupal.org/node/1901550