Bug on order module?

Posts: 33
Joined: 01/30/2008

I keep getting an error when clicking on the Review Order button on checkout.

Fatal error: Unsupported operand types in C:\xampp\htdocs\ubercart\sites\default\modules\ubercart modules\ubercart\uc_order\uc_order.module on line 2891

I've tried to find the problem but I don't think I'm doing anything special.

Thanks

Posts: 2008
Joined: 08/07/2007
AdministratoreLiTe!

In the Bazaar version, that line adds the results of hook_order('total') to the order total. All of the modules I've seen return a number or nothing at all, which wouldn't cause that error. Check through your contrib modules to see which one might be causing the problem. Of course, that might not be the same line in your code, so something else would be at fault.

Posts: 33
Joined: 01/30/2008

I had a function that ended with order.
Ubercart called it but I didn't meant to use a hook.

Should ubercart or me use a namespace to prevent this?

uc_order or something?

Thanks

Posts: 2008
Joined: 08/07/2007
AdministratoreLiTe!

Yeah, you should call it something else. hooks are called based on what's after the module name in the function name. You can add a _ to the beginning to prevent this, but that can be easy to miss, and others reading your code may get confused about what it's supposed to do.

Posts: 33
Joined: 01/30/2008

If a third party module will use order as a function name then it'll break ubercart.

order ending for a module is not such a rare choise...

I changed my code and my problem is solved but I'm concerend about someone else breaking ubercart
by mistake Smiling

Thanks

Posts: 2008
Joined: 08/07/2007
AdministratoreLiTe!

That's an inherent weakness of the hook system. Any two modules that define hooks could have a namespace collision. It happened when we added the workflow-ng requirement because it had a hook_configuration() in it. uc_store_configuration() was a menu page, so it had to be renamed. Which isn't really that big a deal, once you know to look for it.

I don't worry about having a collision over hook_order(). "Order" by itself almost needs some clarification to be useful, unless you're already talking about an ecommerce application. You can't use the e-commerce module along with Übercart anyway, so that isn't a big deal.