Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Double-check term taxonomy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rmccue committed Oct 12, 2015
1 parent c463442 commit baa6db4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/endpoints/class-wp-rest-posts-terms-controller.php
Expand Up @@ -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 ) );
}
}
Expand Down

0 comments on commit baa6db4

Please sign in to comment.