commerce_cart_commerce_order_delete() should be skipped for CLI requests

Created on 18 April 2025, 7 days ago

Describe your bug or feature request.

Currently, whenever cart orders are expired / deleted, we have logic removing the deleted cart from the anonymous user session, this causes the following issue:

#0 /mysite/web/core/lib/Drupal/Core/Session/SessionManager.php(162): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /mysite/web/core/lib/Drupal/Core/Session/SessionManager.php(127): Drupal\Core\Session\SessionManager->startNow()
#2 /mysite/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(311): Drupal\Core\Session\SessionManager->start()
#3 /mysite/vendor/symfony/http-foundation/Session/Session.php(222): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag()
#4 /mysite/vendor/symfony/http-foundation/Session/Session.php(242): Symfony\Component\HttpFoundation\Session\Session->getBag()
#5 /mysite/vendor/symfony/http-foundation/Session/Session.php(69): Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
#6 /mysite/web/modules/contrib/commerce/modules/cart/src/CartSession.php(61): Symfony\Component\HttpFoundation\Session\Session->get()
#7 /mysite/web/modules/contrib/commerce/modules/cart/commerce_cart.module(122): Drupal\commerce_cart\CartSession->deleteCartId()
#8 [internal function]: commerce_cart_commerce_order_delete()
#9 /mysite/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): call_user_func_array()
#10 /mysite/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#11 /mysite/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(415): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#12 /mysite/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(215): Drupal\Core\Extension\ModuleHandler->invokeAll()
#13 /mysite/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
#14 /mysite/web/modules/contrib/commerce/src/CommerceContentEntityStorage.php(56): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
#15 /mysite/web/modules/contrib/commerce/modules/order/src/OrderStorage.php(89): Drupal\commerce\CommerceContentEntityStorage->invokeHook()
#16 /mysite/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(462): Drupal\commerce_order\OrderStorage->invokeHook()
#17 /mysite/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(753): Drupal\Core\Entity\EntityStorageBase->delete()
#18 /mysite/web/modules/contrib/commerce/modules/cart/src/Plugin/QueueWorker/CartExpiration.php(99): Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete()
#19 /mysite/web/core/lib/Drupal/Core/Cron.php(270): Drupal\commerce_cart\Plugin\QueueWorker\CartExpiration->processItem()
#20 /mysite/web/core/lib/Drupal/Core/Cron.php(235): Drupal\Core\Cron->processQueue()
#21 /mysite/web/core/lib/Drupal/Core/Cron.php(162): Drupal\Core\Cron->processQueues()
#22 /mysite/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#23 /mysite/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#24 [internal function]: Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate()
#25 /mysite/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#26 /mysite/vendor/symfony/http-kernel/HttpKernel.php(115): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#27 /mysite/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(66): Symfony\Component\HttpKernel\HttpKernel->terminate()
#28 /mysite/web/core/lib/Drupal/Core/DrupalKernel.php(715): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate()
#29 /mysite/web/index.php(22): Drupal\Core\DrupalKernel->terminate()
#30 {main}

We should be able to safely skip this logic for CLI requests.

📌 Task
Status

Active

Version

3.0

Component

Cart

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024