I just noticed this commit by accident from the map on the new d.o front page... :-)
http://drupal.org/cvs?commit=445622
The hook_hook_info() implementation there is wrong. That hook only lets you define a group for hooks that you "own". system.module owns hook_menu, so only it should get to specify a group for it.
hook_hook_info() defines groups *system wide*, not specific to your module. You can't push code off to another file specific to your module. It's system-wide. If two modules try to define a group/location for the same hook, one of them will get overridden and break because Drupal won't look in its file.
Marking critical as if two modules did this things would break horribly very fast.
Comments
Comment #1
swentel commentedOh god, this is really sad actually :( We did some experiments with Field group & Display Suite today and this was working out fine untill I actually merged now and the delete callback of field group is broken - man this is really really sad.
Why doesn't core use this hook by default - this would made it really easy to split up code more, now you really need some entry points in your .module file again. Urg, back to the drawing board for field group and DS :(
Comment #2
Stalski commentedWhen reading the documentation of this hook, i thought it was a very nice sollution to the problem of having to load only the files when you want them to, instead of hard including the file you want to delegate it too.
So what you say, is that this is totally wrong? (it works like a charm though).
So basically what i did not know, is that the hook defines groups and not what i thought it was doing : mapping a hook to a file (which is the group).
So i have a funny feeling now. Do you have any suggestions on how to achieve the same purpose?
If it is only the menu, then i can live with the fact that it just has to stay in the .module file. If the other ones need to go, then i am looking for a sollution.
Crell, can you pm me on IRC for this, to discuss it a bit (i persume, as i read this, ... ) it will be mostly you explaining me what i don't get from the documenation. This is a bit important since we already put this in other contribs as well.
Conclusion: i thought this was helping us to get the feature "hey drupal, that hook can be found there and you only have to load it if the implementation is asked for".
Comment #3
Stalski commented@swentel sorry, was typing , did not see your posting then.
Comment #4
Stalski commentedAfter reading the documentation again, i think i got it and the conclusion is indeed unbelievably sad. I cannot use this hook in field_group as well, as the field_group implementations are not that long and i like them in the module file. The incredible ugly form_alter functions will have to go to the .module file or do a hard include there to delegate it to the feature group.
Well i will stop wining and start refactoring in another way. Any tips would greatly be appreciated to achieve the effect of not having to include a group.inc file yourself, but only when a hook implementation is fired.
Comment #5
Crell commentedI wish core were using this more, but that got kabashed on DX grounds (that I believe were spurious) and on "gah, stop moving code around when we're in code freeze" grounds (despite it being many months ago now).
Yeah, I'm going to try to fix that in Drupal 8. Until then, yeah, it's only a half-assed implementation.
This hook IS a solution to what you describe, but it's system-wide, not per-module. (Per module would have been horribly complex and slow to implement along the critical path.) That means it can only be implemented by the owning module, not by an implementing module.
I hope there aren't too many contribs that got that backward... :-(
Comment #6
Stalski commentedWell thx for telling us to hold our horses. Refactored and Fixed
Comment #7
swentel commentedthe field_group_hook_info() was still left over - removed and commited.