Describe your bug or feature request.
Whenever I remove an item (the only item) that's in the cart using remove button, I am receiving a WSOD.
This happens only if I switch the currency mid way using currency resolver block (more details below).
Here's the error:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\commerce_cart\CartManager::removeOrderItem() must implement interface Drupal\commerce_order\Entity\OrderInterface, null given, called in C:\wamp64\www\modules\contrib\commerce\modules\cart\src\Plugin\views\field\RemoveButton.php on line 121 in Drupal\commerce_cart\CartManager->removeOrderItem() (line 156 of modules\contrib\commerce\modules\cart\src\CartManager.php).
Drupal\commerce_cart\CartManager->removeOrderItem(NULL, Object) (Line: 121)
Drupal\commerce_cart\Plugin\views\field\RemoveButton->viewsFormSubmit(Array, Object) (Line: 188)
Drupal\views\Form\ViewsFormMainForm->submitForm(Array, Object) (Line: 187)
Drupal\views\Form\ViewsForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('views_form_commerce_cart_form_default_96', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 219)
Drupal\Core\Form\FormBuilder->getForm(Object, Object, Array) (Line: 2258)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 786)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 377)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
If a bug, provide steps to reproduce it from a clean install.
Commerce Core 2.25
Commerce Currency Resolver 1.60
(I have internal page cache disabled, if that matters, I had to disable it to make currency resolver work for anonymous users).
The currency resolver is set to work on Cookie (currency block selector).
I am testing an item, 1000EUR worth \( ^_^ )/
1. Adding it to the cart using a user (regardless if it's just authenticated user or superadmin). (NOTE: if I remove the item at this point, it works fine).
I have a Currency Resolver block at the bottom, in the footer area. The item is displayed in EUR.
2. I click on the currency resolver and change from EUR to USD (if I go the other way it's same result).
3. Ok, now I want to remove the item, after the currency change.
4. WSOD (the one included above).
NOTE:
The WSOD happens only whenever I click on the remove button. BUT, if instead of Just put 0 instead of 1 in the items number. That clears the cart without any error.
So yeah, big think.
Hope you guys can figure this one out. For now I will try to make a button myself that would change number of items to 0 as a workaround.
UPDATE:
Did some more testing.
Just to add here.
The error does not happen if I change the currency prior to actually adding the item to the cart. It happens only if I change currency with the item already in the cart.
Also, promotion does not affect this. I have tested without the discount and the same error shows up.