From 1d9f71fee578c3a4341ca92cb468e45a3674c5b3 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 23 Feb 2017 12:09:39 +0000 Subject: [PATCH] Wrap read with try catch block --- includes/class-wc-customer.php | 7 ++++++- includes/data-stores/class-wc-customer-data-store.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 28bf919ed1d..6b2df5d8f02 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -100,7 +100,12 @@ class WC_Customer extends WC_Legacy_Customer { // If we have an ID, load the user from the DB. if ( $this->get_id() ) { - $this->data_store->read( $this ); + try { + $this->data_store->read( $this ); + } catch ( Exception $e ) { + $this->set_id( 0 ); + $this->set_object_read( true ); + } } else { $this->set_object_read( true ); } diff --git a/includes/data-stores/class-wc-customer-data-store.php b/includes/data-stores/class-wc-customer-data-store.php index 8471f22b7fa..09e50fea532 100644 --- a/includes/data-stores/class-wc-customer-data-store.php +++ b/includes/data-stores/class-wc-customer-data-store.php @@ -114,6 +114,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat * * @since 2.7.0 * @param WC_Customer + * @throws Exception */ public function read( &$customer ) { global $wpdb;