Closed
Description
Preconditions
- Magento CE 2.1.5
- MariaDB 10.1.20
- PHP 7.0.14
Steps to reproduce
- We created a custom shipping carrier. This shipping carrier implements the method
public function collectRates(RateRequest $request)
. - Log in as a customer.
- Add some products to your quote.
- Do not go to checkout. Log off.
- Change some product and/or catalog price rules which affect the products in the quote from step 2. This should set the attribute
trigger_recollect
to1
(integer) for that quote because of
\Magento\Sales\Observer\Backend\CatalogProductSaveAfterObserver::execute()
and
\Magento\Sales\Observer\Backend\CatalogPriceRule::execute()
. - If you now log back in as a customer, your previous quote will be loaded.
- If you then add a product, the shipping rate from our custom shipping carrier will be collected. We use
\Magento\Checkout\Model\Cart::getQuote()
to do some checks.\Magento\Quote\Model\Quote::_afterLoad()
will eventually be triggered, which calls\Magento\Quote\Model\Quote::collectTotals()
if the attributetrigger_recollect
is set to1
. - Now, things begin to repeat because the rates for our custom shipping carrier are collected again.
- A timeout appears because of this loop.
- The customer cannot open any other page on the website, because this cycle continues for that customer. After waiting for the page to finish loading, all the customer will see in the end is a HTTP error 503.
Expected result
- The attribute
trigger_recollect
in a quote should be set to0
(integer) at some time.
Actual result
- In all the magento code, I could only see the attribute
trigger_recollect
in a quote being set to1
, but never back to0
.
My patch, which seems to work fine, is:
In \Magento\Quote\Model\Quote::_afterLoad()
add a reset of the attribute trigger_recollect
after collecting the totals:
protected function _afterLoad()
{
// collect totals and save me, if required
if (1 == $this->getData('trigger_recollect')) {
$this
->collectTotals()
->setTriggerRecollect(0) // patch: reset the attribute trigger_recollect
->save();
}
return parent::_afterLoad();
}
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.1 release lineThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedThe issue has been reproduced on latest 2.1 release