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

bdragon’s picture

Status: Active » Closed (works as designed)

Yes, 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.

gurubert’s picture

Hi,

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?

gurubert’s picture

Version: 4.7.3 » 6.4
Status: Closed (works as designed) » Active
gurubert’s picture

Version: 6.4 » 6.x-dev
Category: bug » feature
sun’s picture

Status: Active » Closed (won't fix)

This cannot be fixed. It is also (already) documented in http://drupal.org/node/158043, but could probably be noted elsewhere, too.

gurubert’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (won't fix) » Active

Hi,

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.

matt2000’s picture

Category: feature » bug

I 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.

berdir’s picture

Status: Active » Closed (duplicate)

a) 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..