1

I'm totaling Ubercart orders grouped by credit card type (VISA, MC, etc). Given the order id, I can 1. load the order object using uc_order_load($order['order_id'], TRUE) 2. and use $order_obj->payment_details['cc_type'] to get the card type. However, my query is resulting in a long list of order_ids, so I'd be loading a lot of order objects.

My page hangs when my query returns more than around 10 order ids, showing only

Service Unavailable

The service is temporarily unavailable. Please try again later.

Which goes away when I comment out the object loading.

So I'm guessing I have too many order objects loaded. I tried using the reset argument to uc_order_load, but saw no effect. I've seen this before with custom objects. So how do I manage this load of objects, please?

(Drupal 6)

4
  • 2
    this sounds like some out of memory or script execution time errors. what much memory may a php script consume at this time? (it's configured in php.ini file) – Andre Baumeier Mar 14 '13 at 0:00
  • @serpiente 256 MB. I agree that it sounds like I'm out of memory. No matter how much memory I assign, I'd be likely to run out, since I expect to be loading at least 10x more orders. It's been suggested offline that I need to apply some garbage collection. I don't yet know how to do that properly. Basically, I need to load each order but only to get the cc_type. Then I don't need it anymore. Can I unload it? – Michael Greisman Mar 17 '13 at 19:46
  • drupalcontrib.org/api/drupal/… it does not look like that the function itself has any static cache so just clear the variable through unset(). you might want to profile your application further and see if there are any other memory leaks. take a look inside the uc_order_load function as well, using your approach will cause a lot of mysql queries what is stupid. best solution is querying the database directly selecting the cc_type – Andre Baumeier Mar 17 '13 at 21:14
  • @Serpiente Again I agree that it'd be better to query the db directly, but I'm pretty certain that the payment_details method is querying a payment service to get the CC type. The CC type isn't already stored in the db for security reasons... sigh. I'll try unset, and I'll look at uc_order_load & the payment_details again when i can. – Michael Greisman Mar 18 '13 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.