diff --git a/plugins/woocommerce/changelog/fix-39354 b/plugins/woocommerce/changelog/fix-39354 new file mode 100644 index 00000000000..a2c0091215d --- /dev/null +++ b/plugins/woocommerce/changelog/fix-39354 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Prevent possible fatal error when edit lock is held on deleted order. diff --git a/plugins/woocommerce/src/Internal/Admin/Orders/EditLock.php b/plugins/woocommerce/src/Internal/Admin/Orders/EditLock.php index 0219ae97c1a..1c5aa71ff37 100644 --- a/plugins/woocommerce/src/Internal/Admin/Orders/EditLock.php +++ b/plugins/woocommerce/src/Internal/Admin/Orders/EditLock.php @@ -100,7 +100,7 @@ class EditLock { } $order = wc_get_order( $order_id ); - if ( ! current_user_can( get_post_type_object( $order->get_type() )->cap->edit_post, $order->get_id() ) && ! current_user_can( 'manage_woocommerce' ) ) { + if ( ! $order || ( ! current_user_can( get_post_type_object( $order->get_type() )->cap->edit_post, $order->get_id() ) && ! current_user_can( 'manage_woocommerce' ) ) ) { return $response; }