Merge pull request #13311 from woocommerce/fix-13297

Wrap read with try catch block
This commit is contained in:
Claudio Sanches 2017-02-23 17:49:55 -03:00 committed by GitHub
commit b51a160369
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;