Posted by sun on January 18, 2013 at 6:31pm
16 followers
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | base system |
| Category: | task |
| Priority: | normal |
| Assigned: | Dave Reid |
| Status: | closed (fixed) |
| Issue tags: | API clean-up |
Issue Summary
hook_hook_info_alter(), really?
Is anyone able to make up a braindead use-case for that? :)
Comments
#1
Yes, 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...
#2
I 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).
#3
Here's a patch.
#4
I'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:
#5
+1 to #4.
#6
Works for me as well.
#7
#8
Given that Dave had a problem -- does this work for you?
#9
It 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.
#10
Wait a sec, appears I'm a victim of api.drupal.org being very out of date. Attempting to confirm locally.
#11
Ok 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.
#12
Committed/pushed to 8.x. We should add a change notice.
#13
Change notice added: http://drupal.org/node/1901550
#14
Automatically closed -- issue fixed for 2 weeks with no activity.