From 9f7387570547ecda8f8ef1ff62b10b52c6eac82c Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 16 Oct 2017 18:35:47 +0000 Subject: [PATCH] Don't force distinct term queries when specifying `number` and `object_ids`. This reverts [41377], which caused performance problems on sites with a large number of terms. See #41796. Built from https://develop.svn.wordpress.org/trunk@41880 git-svn-id: http://core.svn.wordpress.org/trunk@41714 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-term-query.php | 15 ++------------- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index be37596031..8e7404e141 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -553,16 +553,6 @@ class WP_Term_Query { $limits = ''; } - $do_distinct = false; - - /* - * Duplicate terms are generally removed when necessary after the database query. - * But when a LIMIT clause is included in the query, we let MySQL enforce - * distinctness so the count is correct. - */ - if ( ! empty( $limits ) && 'all_with_object_id' !== $args['fields'] ) { - $do_distinct = true; - } if ( ! empty( $args['search'] ) ) { $this->sql_clauses['where']['search'] = $this->get_search_sql( $args['search'] ); @@ -580,7 +570,8 @@ class WP_Term_Query { if ( ! empty( $meta_clauses ) ) { $join .= $mq_sql['join']; $this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] ); - $do_distinct = true; + $distinct .= "DISTINCT"; + } $selects = array(); @@ -642,8 +633,6 @@ class WP_Term_Query { $where = implode( ' AND ', $this->sql_clauses['where'] ); - $distinct = $do_distinct ? 'DISTINCT' : ''; - /** * Filters the terms query SQL clauses. * diff --git a/wp-includes/version.php b/wp-includes/version.php index d8cece5c0c..274a73765d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta2-41879'; +$wp_version = '4.9-beta2-41880'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.