WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/19/2016 02:12:48 AM (4 years ago)
Author:
boonebgorges
Message:

Taxonomy: Improve back compat of values passed to 'terms_clauses' filter.

Prior to the introduction of WP_Term_Query, the 'orderby' clause
passed to the 'terms_clauses' filter was prefixed by ORDER BY. After
WP_Term_Query, this was not the case; ORDER BY was added after the
filter. As such, plugins filtering 'terms_clauses' and returning an
'orderby' clause beginning with ORDER BY resulted in invalid syntax
when WP_Term_Query prepended a second ORDER BY keyword to
the clause.

This changeset rearranges the way the 'orderby' clause is built so that
it will be passed to 'terms_clauses' in the previous format.

Fixes #37378.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-term-query.php

    r38020 r38099  
    385385
    386386        $orderby = $this->parse_orderby( $this->query_vars['orderby'] );
     387        if ( $orderby ) {
     388            $orderby = "ORDER BY $orderby";
     389        }
     390
    387391        $order = $this->parse_order( $this->query_vars['order'] );
    388392
     
    619623        $this->sql_clauses['select']  = "SELECT $distinct $fields";
    620624        $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" : '';
    622626        $this->sql_clauses['limits']  = $limits;
    623627
Note: See TracChangeset for help on using the changeset viewer.