[wp-trac] [WordPress Trac] #40496: get_the_terms() doesn't respect register_taxonomy()'s 'orderby' => 'term_order'

WordPress Trac noreply at wordpress.org
Thu Apr 20 12:59:18 UTC 2017


#40496: get_the_terms() doesn't respect register_taxonomy()'s 'orderby' =>
'term_order'
-----------------------------+-------------------------
 Reporter:  danielbachhuber  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  4.7.5
Component:  Taxonomy         |    Version:  4.7
 Severity:  normal           |   Keywords:  needs-patch
  Focuses:                   |
-----------------------------+-------------------------
 The following test passes in 4.6 and fails in 4.7:

 {{{
 public function test_get_the_terms_should_respect_taxonomy_orderby() {
         register_taxonomy( 'wptests_tax', 'post', array(
                 'sort' => true,
                 'args' => array(
                         'orderby' => 'term_order',
                 ),
         ) );
         $term_ids = self::factory()->term->create_many( 2, array(
                 'taxonomy' => 'wptests_tax',
         ) );
         $post_id = self::factory()->post->create();
         wp_set_object_terms( $post_id, array( $term_ids[0], $term_ids[1]
 ), 'wptests_tax' );
         $terms = get_the_terms( $post_id, 'wptests_tax' );
         $this->assertEquals( array( $term_ids[0], $term_ids[1] ),
 wp_list_pluck( $terms, 'term_id' ) );
         // Flip the order
         wp_set_object_terms( $post_id, array( $term_ids[1], $term_ids[0]
 ), 'wptests_tax' );
         $terms = get_the_terms( $post_id, 'wptests_tax' );
         $this->assertEquals( array( $term_ids[1], $term_ids[0] ),
 wp_list_pluck( $terms, 'term_id' ) );
 }
 }}}

 I haven't tracked down the source of the break though.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40496>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list