From baa6db4a4d1acddbe22339abeb9197503664a119 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Mon, 12 Oct 2015 12:03:07 +1000 Subject: [PATCH] Double-check term taxonomy This changed in trunk's r34997. term_taxonomy_id now always succeeds, even if the taxonomy specified does not match, so we need to double-check this ourselves. --- lib/endpoints/class-wp-rest-posts-terms-controller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/endpoints/class-wp-rest-posts-terms-controller.php b/lib/endpoints/class-wp-rest-posts-terms-controller.php index 2d70ff317a..42f30b5dc1 100644 --- a/lib/endpoints/class-wp-rest-posts-terms-controller.php +++ b/lib/endpoints/class-wp-rest-posts-terms-controller.php @@ -200,7 +200,8 @@ protected function validate_request( $request ) { if ( ! empty( $request['term_id'] ) ) { $term_id = absint( $request['term_id'] ); - if ( ! get_term_by( 'term_taxonomy_id', $term_id, $this->taxonomy ) ) { + $term = get_term_by( 'term_taxonomy_id', $term_id, $this->taxonomy ); + if ( ! $term || $term->taxonomy !== $this->taxonomy ) { return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) ); } }