Uncaught TypeError: Drupal\commerce_payment\PaymentOrderUpdater::updateOrder(): Argument #1 ($order) must be of type Drupal\commerce_order\Entity\OrderInterface, null given,

Created on 25 August 2023, over 1 year ago
Updated 26 October 2023, about 1 year ago

Describe your bug or feature request.

Seeing this error when rolling back migrations.

PHP Fatal error: Uncaught TypeError: Drupal\commerce_payment\PaymentOrderUpdater::updateOrder(): Argument #1 ($order) must be of type Drupal\commerce_order\Entity\OrderInterface, null given, called in /var/www/html/web/modules/contrib/commerce/modules/payment/src/PaymentOrderUpdater.php on line 59 and defined in /var/www/html/web/modules/contrib/commerce/modules/payment/src/PaymentOrderUpdater.php:67

Here is the offending function:

  /**
   * {@inheritdoc}
   */
  public function updateOrders() {
    if (!empty($this->updateList)) {
      /** @var \Drupal\commerce_order\OrderStorage $order_storage */
      $order_storage = $this->entityTypeManager->getStorage('commerce_order');
      foreach ($this->updateList as $order_id) {
        $order = $order_storage->loadForUpdate($order_id);
        $this->updateOrder($order, TRUE);
      }
    }
  }

Maybe in the foreach loop, before we call $this->updateOrder($order, TRUE); we should check

if (!$order) {
  continue;
}
🐛 Bug report
Status

Fixed

Version

2.0

Component

Payment

Created by

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

Comments & Activities

Production build 0.71.5 2024