Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | delete-order-with-payment-2762119-4.patch | 1.22 KB | bjaxelsen |
delete_order_payment.patch | 1.21 KB | bjaxelsen | |
|
Comments
Comment #2
TR CreditAttribution: TR commentedI 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.
Comment #3
rfayMore 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.
Comment #4
bjaxelsen CreditAttribution: bjaxelsen at Fagkommunikation for BYG-ERFA commented@rfay I chenged it slightly and now it works fine with the new patch - can you check?