Don't require explicit taxonomy when getting terms by term_taxonomy_id.

Props wonderboymusic.
Fixes #30620.

git-svn-id: https://develop.svn.wordpress.org/trunk@34679 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-09-29 03:51:11 +00:00
parent 58d7f89bf7
commit 36af857315
2 changed files with 40 additions and 4 deletions
+23
View File
@@ -36,4 +36,27 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase {
$found = get_term_by( 'slug', 'nas', 'wptests_tax' );
$this->assertSame( $t, $found->term_id );
}
/**
* @ticket 30620
*/
public function test_taxonomy_should_be_ignored_if_matching_by_term_taxonomy_id() {
global $wpdb;
register_taxonomy( 'wptests_tax', 'post' );
$t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
$term = get_term( $t, 'wptests_tax' );
$new_ttid = $term->term_taxonomy_id + 1;
// Offset just to be sure.
$wpdb->update(
$wpdb->term_taxonomy,
array( 'term_taxonomy_id' => $new_ttid ),
array( 'term_id' => $t )
);
$found = get_term_by( 'term_taxonomy_id', $new_ttid, 'foo' );
$this->assertSame( $t, $found->term_id );
}
}