I had a theme and a module with the same name (both customized for my site, so using the name seemed like a good idea), but when I defined a hook_block() in my module, suddenly all my blocks stopped working..
After some debug_backtrace()ing, I figured out that drupal was calling my hook_block() function as if it was a theme_block() function (presumably, since the naming convention is the same).. so it was expecting my hook to render the output, when my hook really had no idea why it was getting an object in $op instead of string.
This seems like it may be a major issue, since the only solution may be to redefine the name convention of all theme and/or hook functions... Otherwise, a workaround is simply "don't use the same name for themes and modules".
(I filed this under 'base system' since I'm not really sure to classify it as a theme, block or hook problem, feel free to reassign someone more appropriate)
Comments
Comment #1
bdragon commentedYes, naming a theme and a module the same will break things horribly.
The official solution is "Don't do that."
There is no way around this. Modules and themes share the same namespace.
Comment #2
gurubert commentedHi,
I just stumbled across this including the same debug backtracing effort.
Could the "Don't do that" be made very prominent somewhere, like maybe list in the Status Report a failure if a module and a theme with the same name exist?
Comment #3
gurubert commentedComment #4
gurubert commentedComment #5
sunThis cannot be fixed. It is also (already) documented in http://drupal.org/node/158043, but could probably be noted elsewhere, too.
Comment #6
gurubert commentedHi,
I know that the original issue cannot be fixed.
But it should be possible to add a warning to the status report page (as is done when security updates are available).
This way an admin would be immediately notified if a module and a theme name conflict.
Comment #7
matt2000 commentedI believe this particular name collision could be resolved by naming hook_block something else. So it CAN be fixed in a major release anyway...
Despite the well known fact that modules & themes share name space, collision caused by the hook system and the theme() system is a bug, IMO...
It's not like developers made a mistake or failed to use proper convention in naming functions, and with the growing number of theme and modules, it's more & more likely to get this by accident.
Comment #8
berdira) hook_block() is splitted up into hook_block_$op() in HEAD.
b) There is a issue to disallow naming a module and theme the same way, see #371375: Do not allow a module and theme to use the same name..