6

Problem: Some Customer (< 0.5%) got stuck in an endless loop if they visit our Shop (v1.9.2.4) or add a Product to cart. If the Customer delete the Cookies, everything works fine.

Because I can't reproduce the Problem on my local Maschine, I wrote a Script which do a curl Requests with every single session_id and log all 5xx errors.
With this Method I got a couple "bad" sessions and trace down a loop with xdebug. I figured out, that the endless loop appears if the flag sales_flat_quote.trigger_recollect is set to 1.

app/code/core/Mage/Sales/Model/Quote.php:1375

protected function _afterLoad()
{
    // collect totals and save me, if required
    if (1 == $this->getData('trigger_recollect')) {
        $this->collectTotals()->save();
    }
    return parent::_afterLoad();
}

Trace of the Loop:

  1. The third-party Module Idev_OneStepCheckout listen to sales_quote_collect_totals_before and Call Mage::helper('payment')->getStoreMethods($store, $quote)
  2. This Helper Call the method getConfigData() by a dynamic Model from the current Payment Methods. Module: Payone_Core
  3. getConfig() call another Method which trigger the collectTotals()

A classic infinity Observer loop.

My first approach was to figure out where Magento set trigger_recollect to 1.

$ grep -nre "trigger_recollect\|triggerRecollect" --ignore-case

I found this two places:

app/code/core/Mage/Sales/Model/Resource/Quote.php:207 app/code/core/Mage/Sales/Model/Resource/Quote.php:282

Magento only call this Methods if you have Catalog Price Rules and change the affected Products. Then all quotes with this Product got the trigger_recollect flag. But we don't have any Price Rules and the Problem appears for new customer without a existing Quote, too.

Because of this two functions, I'm not longer sure if the specific loop is the result of the flag and this is very frustrating, because I can't explain why the trigger_recollect is set.

All logs (Magento, Nginx, PHP) are empty. Except this message:

Maximum execution time of 30 seconds exceeded

What I also tried was to compare the raw Data of a "normal" Session and a "bad" Session. Both are exactly the same.

A quick and dirty fix would be to rewrite two third party modules, and pass the quote through all method the prevent the getQuote() call, but there should be a reason why Magento set thetrigger_recollect flag or new customer git stuck, too.

Does anybody has a solution or an idea what i can also try or check?

1 Answer 1

4

looks like there are a lot more call of the particular methods which changes the trigger_recollect flag. The final solution was to pass the Quote through all methods. The Problem was the result of two third party modules.

Not the answer you're looking for? Browse other questions tagged or ask your own question.