Prevent possible fatal error when user holds edit lock for a deleted order (#39497)

* Prevent possible fatal error when locked order is deleted

* Add changelog
This commit is contained in:
Jorge A. Torres 2023-08-01 18:37:49 -03:00 committed by GitHub
parent 62645e0ba8
commit 14d9760549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Prevent possible fatal error when edit lock is held on deleted order.

View File

@ -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;
}