When you delete an order that holds a registered payment, it causes an error. This is because the process goes as:

  • order entity is deleted
  • uc_payment_uc_order_delete() is called (hook_ENTITY_ID_delete)
  • uc_payment_receipt entities are deleted
  • uc_payment_uc_payment_receipt_delete() is called (hook_ENTITY_ID_delete)
  • uc_payment_uc_payment_receipt_delete() depends on the order entity to be available (but it is deleted)

I've made a patch to check if the $order is available or not in uc_payment_uc_payment_receipt_delete() before trying to log a message on the order.

Another way to go would be to change uc_payment_uc_order_delete() to uc_payment_uc_order_predelete() so that the order object is available.

Members fund testing for the Drupal project. Drupal Association Learn more


bjaxelsen created an issue. See original summary.

TR’s picture

Status: Needs review » Needs work

I prefer your suggestion about putting it in the predelete - I think that's the appropriate place to remove things that may depend on the order entity.

It would also be great to add a test to the payment module test, to make sure an order with a payment can be deleted without error. I think the current tests just test deleting the payment, and not deleting an order with a payment.

rfay’s picture

More information about how to replicate and the specific error:

1. Create and pay for an order (I used the test gateway provided by uc_payment)
2. Go to the orders page and use the pulldown to delete the order. For example, admin/store/orders/9/delete
3. Click "Delete" on the confirm page.

You get this fatal:

Fatal error: Call to a member function logChanges() on null in /Users/rfay/workspace/d8git/modules/ubercart/payment/uc_payment/uc_payment.module on line 191

The provided patch does resolve this issue.

bjaxelsen’s picture

@rfay I chenged it slightly and now it works fine with the new patch - can you check?