Merge pull request #17042 from victorfreitas/fix_invalid_term

Fix bug when parent term is invalid
This commit is contained in:
Mike Jolley 2017-10-04 14:55:12 +01:00 committed by GitHub
commit 7e06a30eea
1 changed files with 2 additions and 1 deletions

View File

@ -378,7 +378,8 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
$parent = get_term( (int) $request['parent'], $taxonomy );
if ( ! $parent ) {
// If is null or WP_Error is invalid parent term.
if ( ! $parent || is_wp_error( $parent ) ) {
return new WP_Error( 'woocommerce_rest_term_invalid', __( 'Parent resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
}