From 01b9ca2292498b555e70242483c24510780fd84e Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 19 Jul 2016 02:13:28 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@38099 git-svn-id: http://core.svn.wordpress.org/trunk@38040 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-term-query.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index cfb4474d05..2d3d085af3 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -384,6 +384,10 @@ class WP_Term_Query { } $orderby = $this->parse_orderby( $this->query_vars['orderby'] ); + if ( $orderby ) { + $orderby = "ORDER BY $orderby"; + } + $order = $this->parse_order( $this->query_vars['order'] ); if ( $taxonomies ) { @@ -618,7 +622,7 @@ class WP_Term_Query { $this->sql_clauses['select'] = "SELECT $distinct $fields"; $this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join"; - $this->sql_clauses['orderby'] = $orderby ? "ORDER BY $orderby $order" : ''; + $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; $this->sql_clauses['limits'] = $limits; $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; diff --git a/wp-includes/version.php b/wp-includes/version.php index 957c826e7b..e7bc169248 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-beta3-38098'; +$wp_version = '4.6-beta3-38099'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.