Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout/Cart visit results in error (500) after update 2.2.1 -> 2.2.2 #12655

Closed
fwolfst opened this issue Dec 12, 2017 · 32 comments
Closed

Checkout/Cart visit results in error (500) after update 2.2.1 -> 2.2.2 #12655

fwolfst opened this issue Dec 12, 2017 · 32 comments
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@fwolfst
Copy link

fwolfst commented Dec 12, 2017

Preconditions

  1. Using magento 2.2.2 (updated from 2.2.1), none of the new features.
  2. php, mysql and other libraries current from vanilla ubuntu 16.04

Steps to reproduce

  1. Populate cart, visist https://shop/checkout/cart

Expected result

  1. Get served a cart page as in magento 2.2.1

Actual result

  1. Magento answers with a snippet of shipping stuff (in our case translated "Versandgebühren hier abrufen") in a block-shipping div nicely wrapped in a HTTP 500 response.
    The log shows:
2017/12/12 20:56:09 [error] 13026#13026: *1925924 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/XXX/vendor/magento/module-quote/Model/Cart/Totals.php:592
Stack trace:
#0 /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals->setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension))
#1 /var/www/XXX/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper->_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...')
#2 /var/www/XXX/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper->popu" while reading response header from upstream, client: 127.0.0.1, server: XXX, request: "GET /checkout/cart/ HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "XXX", referrer: "https://XXX/myproduct.html"
@fwolfst fwolfst changed the title Checkout/Cart shows error after update 2.2.1 -> 2.2.2 Checkout/Cart visit results in error (500) after update 2.2.1 -> 2.2.2 Dec 12, 2017
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 12, 2017
@fwolfst
Copy link
Author

fwolfst commented Dec 12, 2017

This only happens if there are items in cart, once I delete them I see again a happy "empty cart"- kind of page. And not reproducibly so (well - only in a new incognito browser window it works fine).

@webazad
Copy link

webazad commented Dec 15, 2017

Facing same problem

@darinda
Copy link

darinda commented Dec 15, 2017

I can confirm the same problem arising on my magento2 installation after upgrading from 2.2.1 to 2.2.2. Downgrading back to 2.2.1 fixes the problem.

@wilzon008
Copy link

I am having the same issue as well.

@friimaind
Copy link

friimaind commented Dec 21, 2017

I am having the same issue.

Magento 2.2.2 upgraded from 2.1.9

Happens with new or logged customers

Apache error log:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\\Quote\\Model\\Cart\\Totals::setExtensionAttributes() must be an instance of Magento\\Quote\\Api\\Data\\TotalsExtensionInterface, instance of Magento\\Quote\\Api\\Data\\AddressExtension given, called in /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/Totals.php:592\nStack trace:\n#0 /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\\Quote\\Model\\Cart\\Totals->setExtensionAttributes(Object(Magento\\Quote\\Api\\Data\\AddressExtension))\n#1 /var/www/www.mywebsite.com/public_html/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\\Framework\\Api\\DataObjectHelper->_setDataValues(Object(Magento\\Quote\\Model\\Cart\\Totals), Array, 'Magento\\\\Quote\\\\A...')\n#2 /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\\F in /var/www/www.mywebsite.com/public_html/vendor/magento/module-quote/Model/Cart/Totals.php on line 592, referer: https://www.mywebsite.com/it/checkout/

image

@twa8000
Copy link

twa8000 commented Dec 23, 2017

Same issue. Only happens when your logged into a customer account with items in your cart.

@cmuench
Copy link
Contributor

cmuench commented Dec 29, 2017

I have this issue also if a payment failed after the customer returns to the cart page.

@mombrea
Copy link

mombrea commented Dec 29, 2017

I have this issue after upgrading to 2.2.2 as well. Only happens for logged in users. Creating a new user account works for a time and then starts failing.

With PHP errors on the last output is:

window.checkoutConfig = <br />
--
  | <b>Fatal error</b>:  Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/Totals.php:592
  | Stack trace:
  | #0 /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals-&gt;setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension))
  | #1 /var/www/clients/client3/web4/web/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper-&gt;_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...')
  | #2 /var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper-&gt;populateW in <b>/var/www/clients/client3/web4/web/vendor/magento/module-quote/Model/Cart/Totals.php</b> on line <b>592</b><br />

Downgrading to 2.2.1 solved the problem.

@JonnyStecchino
Copy link

I am having the same issue.
Magento 2.2.2 upgraded from 2.1.10

@bydrei
Copy link

bydrei commented Jan 4, 2018

@JonnyStecchino, @mombrea, @friimaind, @fwolfst, @cmuench, @twa8000, @webazad, @darinda This was an issue which had been fixed since 2.1.7 but for some reason it was not merged to 2.2.*. Here is the fix for it aa535e.

I've created a temporary plugin to fix this, so you could also do the same.

@fwolfst
Copy link
Author

fwolfst commented Jan 6, 2018

@ferrazzuk Awesome. confirm that fix works.

@keywoker
Copy link

@ferrazzuk Hello, Can you add code of your plugin or link ?

@artklassen
Copy link

Hello,
I am using Magento 2.2.2 installed from scratch, not updated from earlier version. I am still experiencing same issue. I tried this fix aa535e it doesn't help.

Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php:592 Stack trace: #0 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(125): Magento\Quote\Model\Cart\Totals-&gt;setExtensionAttributes(Object(Magento\Quote\Api\Data\AddressExtension)) #1 /home/reachf90/public_html/dev18/vendor/magento/framework/Api/DataObjectHelper.php(85): Magento\Framework\Api\DataObjectHelper-&gt;_setDataValues(Object(Magento\Quote\Model\Cart\Totals), Array, 'Magento\\Quote\\A...') #2 /home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/CartTotalRepository.php(103): Magento\Framework\Api\DataObjectHelper-&gt;populateWithAr in <b>/home/reachf90/public_html/dev18/vendor/magento/module-quote/Model/Cart/Totals.php</b> on line <b>592</b><br /> {"messages":{"error":[{"code":500,"message":"Fatal Error: 'Uncaught TypeError: Argument 1 passed to Magento\\Quote\\Model\\Cart\\Totals::setExtensionAttributes() must be an instance of Magento\\Quote\\Api\\Data\\TotalsExtensionInterface, instance of Magento\\Quote\\Api\\Data\\AddressExtension given, called in \/home\/reachf90\/public_html\/dev18\/vendor\/magento\/framework\/Api\/DataObjectHelper.php on line 125 and defined in \/home\/reachf90\/public_html\/dev18\/vendor\/magento\/module-quote\/Model\/Cart\/Totals.php:592\nStack trace:\n#0 \/home\/reachf90\/public_html\/dev18\/vendor\/magento\/framework\/Api\/DataObjectHelper.php(125): Magento\\Quote\\Model\\Cart\\Totals->setExtensionAttributes(Object(Magento\\Quote\\Api\\Data\\AddressExtension))\n#1 \/home\/reachf90\/public_html\/dev18\/vendor\/magento\/framework\/Api\/DataObjectHelper.php(85): Magento\\Framework\\Api\\DataObjectHelper->_setDataValues(Object(Magento\\Quote\\Model\\Cart\\Totals), Array, 'Magento\\\\Quote\\\\A...')\n#2 \/home\/reachf90\/public_html\/dev18\/vendor\/magento\/module-quote\/Model\/Cart\/CartTotalRepository.php(103): Magento\\Framework\\Api\\DataObjectHelper->populateWithAr' in '\/home\/reachf90\/public_html\/dev18\/vendor\/magento\/module-quote\/Model\/Cart\/Totals.php' on line 592","trace":"Trace is not available."}]}}

@OwenMelbz
Copy link

Is there an estimated time for fix and release on this as its a pretty large issue, clearly affecting many people?

Thanks

@flancer64
Copy link
Contributor

I had the same issue and I have created a standalone magento module flancer32/mage2_fix_is12655 based on aa535e to fix it.

@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Feb 16, 2018
@magento-engcom-team
Copy link
Contributor

@fwolfst, thank you for your report.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 16, 2018
@Sil-B
Copy link

Sil-B commented Feb 22, 2018

We are facing the same issues on upgrade from m2.2.1 -> m2.2.2.
The module of @flancer64 works for me! Thanks

@njbair
Copy link

njbair commented Feb 22, 2018

Another confirmation that the issue exists and that @flancer64 's fix works perfectly.

@al1357
Copy link

al1357 commented Mar 8, 2018

In my case the issue appeared after update from 2.1.9 to 2.2.3, @flancer64 's fix worked.

@fluential
Copy link

Same issue here with 2.2.1 -> 2.2.3 @flancer64 is a star!

@vbuck
Copy link

vbuck commented Mar 9, 2018

Same issue here. Upon a closer look, I found some behavior in \Magento\Checkout\Model\TotalsInformationManagement that did not align with similar procedures in the quote module. See excerpt from this class below:

/**
 * {@inheritDoc}
 */
public function calculate(
    $cartId,
    \Magento\Checkout\Api\Data\TotalsInformationInterface $addressInformation
) {
    /** @var \Magento\Quote\Model\Quote $quote */
    $quote = $this->cartRepository->get($cartId);
    $this->validateQuote($quote);

    if ($quote->getIsVirtual()) {
        $quote->setBillingAddress($addressInformation->getAddress());
    } else {
        $quote->setShippingAddress($addressInformation->getAddress());
        $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod(
            $addressInformation->getShippingCarrierCode() . '_' . $addressInformation->getShippingMethodCode()
        );
    }
    $quote->collectTotals();

    return $this->cartTotalRepository->get($cartId);
}

I'm not sure if this is intentional or what the logic is behind this, but the last 2 lines should be re-evaluated, to consider the following:

  • This is the only place where I find totals collection without a wrapping call to save by the repository
  • The quote is presumably reloaded by the repository on the return statement

I was able to solve my issue in a way different from @flancer64 by changing the totals collection call like so:

    $this->cartRepository->save($quote->collectTotals()); 

Alternatively you could return the prepared quote itself instead of reloading from the repository, but I'm unsure of the intention/design of this method to commit a save back on the record. I'd like to hear some thoughts from those more familiar with the architecture here.

@andrewhowdencom
Copy link
Contributor

Still present in 2.3. #12993

@magento-engcom-team magento-engcom-team added the Event: distributed-cd Distributed Contribution Day label Mar 19, 2018
@magento magento deleted a comment from magento-engcom-team Mar 23, 2018
@magento magento deleted a comment from tolyantrain Mar 23, 2018
@magento magento deleted a comment from magento-engcom-team Mar 23, 2018
@magento-engcom-team magento-engcom-team added Award: advanced and removed Event: distributed-cd Distributed Contribution Day labels Apr 13, 2018
@winterk80
Copy link

Also experiencing this in 2.2.3

@lano-vargas
Copy link

I am having this issue on checkout when user has an account for the first time then log out add to cart then at checkout enter email and password hit login I get exactly as described PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() ....
instance of Magento\Quote\Api\Data\AddressExtension given ....

Is there a quick fix?

@vbuck
Copy link

vbuck commented May 16, 2018

@lano-vargas have you tried my suggested fix on the core?

#12655 (comment)

It would be the "quick fix." Short of that, you can do something as an extension, via plugins:

  • Register plugin on webapi_rest/di.xml for \Magento\Checkout\Model\TotalsInformationManagement
  • Implement plugin with method aroundCalculate
  • Change behavior as I prescribed, such that you save the quote before returning it

@popatkaran
Copy link

Working on #dmcdindia

@magento-engcom-team
Copy link
Contributor

@popatkaran thank you for joining. Please accept team invitation here and self-assign the issue.

@0franco
Copy link

0franco commented Jul 6, 2018

Same issue v. 2.2.2, fixed with your module @flancer64 thank you!

@SolRey
Copy link

SolRey commented Jul 16, 2018

Thanks @flancer64 , Yous module fixed my issue in 2.2.3 :)

@RyanZolper
Copy link
Contributor

I have tested this on various versions, including 2.2.3 and 2.3-develop, and confirmed that this issue has been fixed. Below are the relevant pull requests:

Original fix in 2.1-develop (aa535e)
Forwardport to 2.2-develop (https://github.com/magento/magento2ce/pull/1975/files)
Forwardport to 2.3-develop (https://github.com/magento/magento2/pull/17620/files)

CC @okorshenko

@okorshenko
Copy link
Contributor

Hi @RyanZolper Thank you for the research! 👍

@qrider
Copy link

qrider commented Oct 23, 2018

Is this fixed in the latest versions? > 2.2.4? Just wondering if I would need to reapply the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests