This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Don't permit requesting terms cross routes#1764
Merged
danielbachhuber merged 3 commits intodevelopfrom Nov 30, 2015
Merged
Conversation
Clients should only be able to request categories from the category route, and tags from the tag route
Member
Author
|
@WP-API/amigos #reviewmerge |
Member
There was a problem hiding this comment.
How is this possible? My understanding is get_term_by will return null for a term_id that doesn't belong to that taxonomy, and no shared terms should now have stopped that being unexpected.
Member
Author
There was a problem hiding this comment.
How is this possible?
The test case fails as expected on nightly https://travis-ci.org/WP-API/WP-API/jobs/92832027
My understanding is get_term_by will return null for a term_id that doesn't belong to that taxonomy, and no shared terms should now have stopped that being unexpected.
Nope:
} elseif ( 'term_taxonomy_id' == $field ) {
$value = (int) $value;
$_field = 'tt.term_taxonomy_id';
// No `taxonomy` clause when searching by 'term_taxonomy_id'.
$tax_clause = '';
} else {
$term = get_term( (int) $value, $taxonomy, $output, $filter );
if ( is_wp_error( $term ) || is_null( $term ) ) {
$term = false;
}
return $term;
}
$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s $tax_clause LIMIT 1", $value ) );
if ( ! $term )
return false;
// In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db.
if ( 'term_taxonomy_id' === $field ) {
$taxonomy = $term->taxonomy;
}
If term_taxonomy_id is provided, then get_term_by() ignores the provided taxonomy
Member
danielbachhuber
added a commit
that referenced
this pull request
Nov 30, 2015
Don't permit requesting terms cross routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clients should only be able to request categories from the category route, and tags from the tag route
Fixes #1763