magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Temando Shipping assumes no other ExtensionAttribute users #12921

Closed fooman closed 6 years ago

fooman commented 6 years ago

Preconditions

  1. Magento 2.2.2

Steps to reproduce

  1. Create an extension that sets an extension attribute on Magento\Quote\Api\Data\AddressInterface during the quote totals collection process
  2. Create new order via the admin
  3. Click Add Products
  4. Select a product, set quantity to 1 and click Add Selected Products to Order

Expected result

  1. Products are added

Actual result

  1. Server 500 error

`2017/12/29 13:01:10 [error] 347#0: *1657 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Temando\Shipping\Model\Checkout\Address::setServiceSelection() must be of the type array, null given, called in /var/www/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php on line 76 and defined in /var/www/vendor/temando/module-shipping-m2/Model/Checkout/Address.php:78 Stack trace:

0 /var/www/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php(76): Temando\Shipping\Model\Checkout\Address->setServiceSelection(NULL)

1 /var/www/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Temando\Shipping\Observer\SaveCheckoutFieldsObserver->execute(Object(Magento\Framework\Event\Observer))

2 /var/www/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Temando\Shipping\Observer\SaveCheckoutFieldsObserver), Object(Magento\Framework\Event\Observer))

3 /var/www/vendor/magento/framework/Event/Manager.php(66" while reading response header from upstream, client: 172.17.0.3, server: localhost, request: "POST /admin/sales/order_create/loadBlock/block/search,items,shipping_method,totals,giftmessage,billing_method?isAjax=true HTTP/1.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "ce-2-2-2-s9ek75.jenkins.fooman.co.nz", referrer: " https://example.com/admin/sales/order_create/index/"`

Likely culprit is Temando\Shipping\Observer\SaveCheckoutFieldsObserver as this code assumes no other module might be setting extension attributes on the quote address:

    if (!$quoteAddress->getExtensionAttributes()) {
        return;
    }
ahmadvaqaskhan commented 6 years ago

Hi , I am also facing the same issue. I have upgarded from Magento 2.1.7 to 2.2.2. Error Case : When user logins and has items in his cart (originally added in 2.1.7) and tries to add product to cart (now its 2.2.2 as upgarded) , user gets the error

Fatal error: Uncaught TypeError: Argument 1 passed to Temando\Shipping\Model\Checkout\Address::setServiceSelection() must be of the type array, null given, called in /var/www/html/m22/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php on line 73 and defined in /var/www/html/m22/vendor/temando/module-shipping-m2/Model/Checkout/Address.php:78 Stack trace: #0 /var/www/html/m22/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php(73): Temando\Shipping\Model\Checkout\Address->setServiceSelection(NULL) #1 /var/www/html/m22/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Temando\Shipping\Observer\SaveCheckoutFieldsObserver->execute(Object(Magento\Framework\Event\Observer)) #2 /var/www/html/m22/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Temando\Shipping\Observer\SaveCheckoutFieldsObserver), Object(Magento\Framework\Event\Observer)) #3 /var/www/html/m22/vendor/magento/framework/E in /var/www/html/m22/vendor/temando/module-shipping-m2/Model/Checkout/Address.php on line 78

Looking to get some solution for it.

There is no issue when products are added in fresh cart.

fwolfst commented 6 years ago

bin/magento module:disable Temando_Shipping fixes this for us. Thanks @orlangur for pointing out the relation with the other issue. That means to have a 2.2.2 installation that works for customers with adblock you need to disable two foreign modules that were slipped in with 2.2.2 (Dotdigitalgroup_Email being the other one).

romainruaud commented 6 years ago

I am also encountering this issue.

Temando module should not assume he is the only one which is adding extension attributes to addresses...

Of course, disabling Temando_Shipping fixes the issue, but this is not sustainable solution.

Is there anyway to contact the Temando team to have them working on it ? @orlangur could you indicate how we should deal with this one ?

orlangur commented 6 years ago

@romainruaud disabling Temando_Shipping should be just fine until you want to use its functionality. I don't think any kind of hotfix is required, just wait for the official fix shipped with some of the next releases.

pravalitera commented 6 years ago

@orlangur Expecting proper official fix on Magento 2 is like waiting for humanity to stop wars ;)

pfortin-expertime commented 6 years ago

Hi guys,

I have the same issue, you can find an small module which fix it here: MageFix-Temando

magento-engcom-team commented 6 years ago

@fooman, please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue. The GitHub issue tracker is intended for Magento Core technical issues only.

fooman commented 6 years ago

@magento-engcom-team I already had a chat with @antonkril about this and he confirmed it as an issue which is being fixed in the next release of the temando extension.

antonkril commented 6 years ago

cc @buskamuza @kokoc

dan-ding commented 6 years ago

@magento-engcom-team how is this not a magento core issue? The extension wouldn't be there if the magento core didn't include it.

buskamuza commented 6 years ago

It's fixed in Magento 2.2.4

bharatdeai commented 6 years ago

we are facing same issue while shipping method load in checkout in 2.2.4 as well. I have putt error code and screenshot as well.

Fatal error: Uncaught Error: Call to a member function getCheckoutFields() on array in C:\checkxampp\htdocs\m224\vendor\temando\module-shipping-m2\Observer\SaveCheckoutFieldsObserver.php:63 Stack trace:

0 C:\checkxampp\htdocs\m224\vendor\magento\framework\Event\Invoker\InvokerDefault.php(72): Temando\Shipping\Observer\SaveCheckoutFieldsObserver->execute(Object(Magento\Framework\Event\Observer))

1 C:\checkxampp\htdocs\m224\vendor\magento\framework\Event\Invoker\InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Temando\Shipping\Observer\SaveCheckoutFieldsObserver), Object(Magento\Framework\Event\Observer))

2 C:\checkxampp\htdocs\m224\vendor\magento\framework\Event\Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))

3 C:\checkxampp\htdocs\m224\generated\code\Magento\Framework\Event\Manager\Proxy.php(95): Magento\Framework\Event\Manager->dispatch('sales_quote_add...', Array)

4 C:\checkxampp\htdocs\m224\ in C:\checkxampp\htdocs\m224\vendor\temando\module-shipping-m2\Observer\SaveCheckoutFieldsObserver.php on line 63

{"messages":{"error":[{"code":500,"message":"Server internal error. See details in report api\/1453687268"}]}}

Screenshot : http://prntscr.com/jdytt0

IgorVitol commented 6 years ago

@bharatdeai

we are facing same issue while shipping method load in checkout in 2.2.4 as well.

Hi! This looks like another bug, which I just created here - https://github.com/magento/magento2/issues/15026

You probably have custom code which make address save during shipping estimation. Since in core magento, address not saved during "estimate-shipping-methods" request. That's why probably bug was not discovered recently.

This issue related to wrong way on converting & saving input data inside of next class: \Magento\Quote\Model\ShippingMethodManagement::getShippingMethods

So, "extension_attributes" saved as array in result $address object. Which lead to fatal errors.