SendCloud / sendcloud

A Magento 2 module for Sendcloud
9 stars 21 forks source link

Magento 2.4.5 TypeError: Argument 1 passed to Plugin\Cart\CartRepository::afterGet() #151

Closed kretschmer-dmf closed 1 year ago

kretschmer-dmf commented 1 year ago

Used software versions:

Magento 2.4.5 enterprise Sendcloud 2.0.11

We experienced the following issue in our staging environment during the last checkout step.

TypeError: SendCloud\SendCloud\Plugin\Cart\CartRepository::afterGet(): Argument #1 ($subject) must be of type Magento\Quote\Model\QuoteRepository, Magento\AsyncOrder\Model\CartRepository\Interceptor given, called in /var/www/html/vendor/magento/framework/Interception/Interceptor.php on line 146 and defined in /var/www/html/vendor/sendcloud/sendcloud/Plugin/Cart/CartRepository.php:49

Stack trace:

#0 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): SendCloud\SendCloud\Plugin\Cart\CartRepository->afterGet(Object(Magento\AsyncOrder\Model\CartRepository\Interceptor), Object(Magento\Quote\Model\Quote\Interceptor), '580048', Array)
#1 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\AsyncOrder\Model\CartRepository\Interceptor->Magento\Framework\Interception\{closure}('580048', Array)
#2 /var/www/html/generated/code/Magento/AsyncOrder/Model/CartRepository/Interceptor.php(23): Magento\AsyncOrder\Model\CartRepository\Interceptor->___callPlugins('get', Array, Array)
#3 /var/www/html/vendor/magento/module-async-order/Model/CartRepository.php(58): Magento\AsyncOrder\Model\CartRepository\Interceptor->get('580048', Array)
#4 /var/www/html/generated/code/Magento/AsyncOrder/Model/CartRepository/Interceptor.php(41): Magento\AsyncOrder\Model\CartRepository->getActive('580048', Array)
#5 /var/www/html/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php(77): Magento\AsyncOrder\Model\CartRepository\Interceptor->getActive('580048')
#6 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(121): Magento\CheckoutStaging\Plugin\GuestPaymentInformationManagementPlugin->beforeSavePaymentInformationAndPlaceOrder(Object(Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor), 'GrEwwrjSjPHuU07...', 'test@exam...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address\Interceptor))
#7 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}('GrEwwrjSjPHuU07...', 'test@exam...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address\Interceptor))
#8 /var/www/html/generated/code/Magento/Checkout/Model/GuestPaymentInformationManagement/Interceptor.php(23): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callPlugins('savePaymentInfo...', Array, Array)
#9 /var/www/html/vendor/magento/module-async-order/Model/AsyncPaymentInformationGuestPublisher.php(132): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder('GrEwwrjSjPHuU07...', 'test@exam...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address\Interceptor))
#10 [internal function]: Magento\AsyncOrder\Model\AsyncPaymentInformationGuestPublisher->savePaymentInformationAndPlaceOrder('GrEwwrjSjPHuU07...', 'test@exam...', Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address\Interceptor))
#11 /var/www/html/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/magento/module-webapi/Controller/Rest.php(195): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))
#13 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#14 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)
#15 /var/www/html/vendor/fastly/magento2/Model/FrontControllerPlugin.php(128): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Fastly\Cdn\Model\FrontControllerPlugin->aroundDispatch(Object(Magento\Webapi\Controller\Rest\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /var/www/html/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#19 /var/www/html/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
#21 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#22 /var/www/html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#23 {main} [] []

We found a similar exception in #136.

Possible solution:

We fixed the issue by replacing the explicit QuoteRepository implementation with the generic CartRepositoryInterface in a patch file, which solved the issue for us.

teodoratimoti commented 1 year ago

Hello @kretschmer-dmf,

Thank you for reaching out.

Our team will check this issue and we will get back with more information.

Best regards.

tanjalog commented 1 year ago

Hello @kretschmer-dmf

We added the recommended changes and this will be available in the next release.

Thank you very much.

Best regards.

teodoratimoti commented 1 year ago

Hello @kretschmer-dmf ,

Please note that the new plugin version 2.0.13 is released on the Marketplace and GitHub. Best regards.