mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Avoid returning duplicate matches when using a meta query in WP_User_Query.
A meta_query containing an `OR` relation can result in the same record matching multiple clauses, leading to duplicate results. The previous prevention against duplicates [18178] #17582 became unreliable in 4.1 when `WP_Meta_Query` introduced support for nested clauses. The current changeset adds a new method `WP_Meta_Query::has_or_relation()` for checking whether an `OR` relation appears anywhere in the query, and uses the new method in `WP_User_Query` to enforce distinct results as necessary. Props maxxsnake. Fixes #32592. git-svn-id: https://develop.svn.wordpress.org/trunk@32713 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -709,7 +709,7 @@ class WP_User_Query {
|
||||
$this->query_from .= $clauses['join'];
|
||||
$this->query_where .= $clauses['where'];
|
||||
|
||||
if ( 'OR' == $this->meta_query->relation ) {
|
||||
if ( $this->meta_query->has_or_relation() ) {
|
||||
$this->query_fields = 'DISTINCT ' . $this->query_fields;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user