Make WordPress Core


Ignore:
Timestamp:
06/09/2015 05:41:35 PM (10 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r32696 r32713  
    710710            $this->query_where .= $clauses['where'];
    711711
    712             if ( 'OR' == $this->meta_query->relation ) {
     712            if ( $this->meta_query->has_or_relation() ) {
    713713                $this->query_fields = 'DISTINCT ' . $this->query_fields;
    714714            }
Note: See TracChangeset for help on using the changeset viewer.