Changeset 38099
- Timestamp:
- 07/19/2016 02:12:48 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-term-query.php
r38020 r38099 385 385 386 386 $orderby = $this->parse_orderby( $this->query_vars['orderby'] ); 387 if ( $orderby ) { 388 $orderby = "ORDER BY $orderby"; 389 } 390 387 391 $order = $this->parse_order( $this->query_vars['order'] ); 388 392 … … 619 623 $this->sql_clauses['select'] = "SELECT $distinct $fields"; 620 624 $this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join"; 621 $this->sql_clauses['orderby'] = $orderby ? " ORDER BY$orderby $order" : '';625 $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; 622 626 $this->sql_clauses['limits'] = $limits; 623 627 -
trunk/tests/phpunit/tests/term/query.php
r37860 r38099 86 86 $this->assertSame( array( $terms[1], $terms[0], $terms[2] ), $found ); 87 87 } 88 89 /** 90 * @ticket 37378 91 */ 92 public function test_order_by_keyword_should_not_be_duplicated_when_filtered() { 93 register_taxonomy( 'wptests_tax', 'post' ); 94 95 add_filter( 'terms_clauses', array( $this, 'filter_terms_clauses' ) ); 96 $q = new WP_Term_Query( array( 97 'taxonomy' => array( 'wptests_tax' ), 98 'orderby' => 'name', 99 ) ); 100 remove_filter( 'terms_clauses', array( $this, 'filter_terms_clauses' ) ); 101 102 $this->assertContains( 'ORDER BY tt.term_id', $q->request ); 103 $this->assertNotContains( 'ORDER BY ORDER BY', $q->request ); 104 } 105 106 public function filter_terms_clauses( $clauses ) { 107 $clauses['orderby'] = 'ORDER BY tt.term_id'; 108 return $clauses; 109 } 88 110 }
Note: See TracChangeset
for help on using the changeset viewer.