WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/29/2015 03:51:11 AM (6 years ago)
Author:
boonebgorges
Message:

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

Props wonderboymusic.
Fixes #30620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTermBy.php

    r34628 r34679  
    3737        $this->assertSame( $t, $found->term_id );
    3838    }
     39
     40    /**
     41     * @ticket 30620
     42     */
     43    public function test_taxonomy_should_be_ignored_if_matching_by_term_taxonomy_id() {
     44        global $wpdb;
     45
     46        register_taxonomy( 'wptests_tax', 'post' );
     47        $t = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     48        $term = get_term( $t, 'wptests_tax' );
     49
     50        $new_ttid = $term->term_taxonomy_id + 1;
     51
     52        // Offset just to be sure.
     53        $wpdb->update(
     54            $wpdb->term_taxonomy,
     55            array( 'term_taxonomy_id' => $new_ttid ),
     56            array( 'term_id' => $t )
     57        );
     58
     59        $found = get_term_by( 'term_taxonomy_id', $new_ttid, 'foo' );
     60        $this->assertSame( $t, $found->term_id );
     61    }
    3962}
Note: See TracChangeset for help on using the changeset viewer.