Wrap read with try catch block

This commit is contained in:
Mike Jolley 2017-02-23 12:09:39 +00:00
parent c473190756
commit 1d9f71fee5
2 changed files with 7 additions and 1 deletions

View File

@ -100,7 +100,12 @@ class WC_Customer extends WC_Legacy_Customer {
// If we have an ID, load the user from the DB. // If we have an ID, load the user from the DB.
if ( $this->get_id() ) { if ( $this->get_id() ) {
try {
$this->data_store->read( $this ); $this->data_store->read( $this );
} catch ( Exception $e ) {
$this->set_id( 0 );
$this->set_object_read( true );
}
} else { } else {
$this->set_object_read( true ); $this->set_object_read( true );
} }

View File

@ -114,6 +114,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
* *
* @since 2.7.0 * @since 2.7.0
* @param WC_Customer * @param WC_Customer
* @throws Exception
*/ */
public function read( &$customer ) { public function read( &$customer ) {
global $wpdb; global $wpdb;