Make WordPress Core


Ignore:
Timestamp:
11/05/2013 01:18:02 AM (11 years ago)
Author:
wonderboymusic
Message:

Cast proper fields to int when returning from wp_get_object_terms(). Add term_taxonomy_id and object_id to the list in sanitize_term() and sanitize_term_field().

Fixes #17646. Adds unit tests.
Props simonwheatley, dd32, kovshenin.

File:
1 edited

Legend:

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

    r25551 r26010  
    434434    }
    435435
     436    function test_get_object_terms_types() {
     437        $post_id = $this->factory->post->create();
     438        $term = wp_insert_term( 'one', $this->taxonomy );
     439        wp_set_object_terms( $post_id, $term, $this->taxonomy );
     440
     441        $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) ) );
     442        $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
     443        foreach ( $int_fields as $field )
     444            $this->assertInternalType( 'int', $term->$field, $field );
     445
     446        $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) );
     447        $this->assertInternalType( 'int', $term, 'term' );
     448    }
     449
    436450    private function assertPostHasTerms( $post_id, $expected_term_ids, $taxonomy ) {
    437451        $assigned_term_ids = wp_get_object_terms( $post_id, $taxonomy, array(
Note: See TracChangeset for help on using the changeset viewer.