Make WordPress Core

Ticket #21651: 21651.2.diff

File 21651.2.diff, 1.6 KB (added by wonderboymusic, 11 years ago)
  • tests/phpunit/tests/term.php

     
    489489                $this->assertEquals( array( $term4['term_id'] ), $post->post_category );
    490490
    491491                wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'] ), true );
    492                 $this->assertEquals( array( $term2['term_id'], $term4['term_id'],$term1['term_id'] ), $post->post_category );
     492                $this->assertEquals( array( $term2['term_id'], $term4['term_id'], $term1['term_id'] ), $post->post_category );
    493493
    494494                wp_set_post_categories( $post_id, array(), true );
    495495                $this->assertEquals( 1, count( $post->post_category ) );
     
    499499                $this->assertEquals( 1, count( $post->post_category ) );
    500500                $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] );
    501501        }
     502
     503        function test_get_term_by_tt_id() {
     504                $term1 = wp_insert_term( 'Foo', 'category' );
     505                $term2 = get_term_by( 'term_taxonomy_id', $term1['term_taxonomy_id'], 'category' );
     506                $this->assertEquals( get_term( $term1['term_id'], 'category' ), $term2 );
     507        }
    502508}
  • src/wp-includes/taxonomy.php

     
    976976                // Assume already escaped
    977977                $value = wp_unslash($value);
    978978                $field = 't.name';
     979        } else if ( 'term_taxonomy_id' == $field ) {
     980                $value = (int) $value;
     981                $field = 'tt.term_taxonomy_id';
    979982        } else {
    980983                $term = get_term( (int) $value, $taxonomy, $output, $filter);
    981984                if ( is_wp_error( $term ) )