Merge pull request #19157 from woocommerce/fix/api-unit-test

Fix error in unit tests due to missing object check
This commit is contained in:
Claudiu Lodromanean 2018-02-27 08:38:21 -08:00 committed by GitHub
commit ba0c0e72df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -165,7 +165,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
} }
// Check if variation belongs to the correct parent product. // Check if variation belongs to the correct parent product.
if ( 0 !== $object->get_parent_id() && absint( $request['product_id'] ) !== $object->get_parent_id() ) { if ( $object && 0 !== $object->get_parent_id() && absint( $request['product_id'] ) !== $object->get_parent_id() ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Parent product does not match current variation.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Parent product does not match current variation.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
} }