Drupal theme and module naming conflicts
Andrew was having a problem earlier today with a theme's preprocess function not being called in the order he expected. In particular, this function was a THEMENAME_preprocess_node() function. The odd thing was, that when he looked at the theme registry using the handy devel module, the order of preprocess functions was
- THEMENAME_preprocess_node()
- views_preprocess_node()
- phptemplate_preprocess_node()
The phptemplate_preprocess_node function is found in the base theme, so that didn't look out of place. I then realized that the themes preprocess function was being called amongst a bunch of module preprocess functions. That's when the light bulb went off in my head.
It turns out that there was also a module with the same name as the theme. Since php has only a single namespace, THEMENAME_preprocess_node() was interpreted as MODULENAME_preprocess_node(). Yikes!!!
Let's get this fixed in Drupal 7. There is already an issue in the Drupal issue queue to handle these naming conflicts.

2 Responses
This should be an error. As soon as you activate a module that has the same name as the theme or vice versa drupal should fail. I too have wasted hours on this, and have since found out that nearly every developer I work with has the same experience at least once.
A young boy and his dad went out fishing one fine morning. After a few quiet hours out in the boat, the boy became curious about the world around him. He looked up at his dad and asked "How do fish breath under water?"His dad thought about it for a moment, then replied, "I really don't know, son."The boy sat quietly from another moment, then turned back to his dad and asked, "How does our boat float on the water?"Nnce again his dad replied, "Don’t know, son."Pondering his thoughts again, a short while later, the boy asks "Why is the sky blue?"Again, his dad replied. "Don’t know, son."The inquisitive boy, worried he was annoying his father, Tiffany Cuff Links asks this time "Dad, do you mind that I'm asking you all of these questions?""Of course not son." replied his dad, "How else are you ever going to learn anything?"
Post new comment