Make WordPress Core

Changeset 18178


Ignore:
Timestamp:
06/07/2011 03:55:05 PM (13 years ago)
Author:
ryan
Message:

Use DISTINCT to eliminate duplicates when using an OR meta query relation. Props scribu, greuben. fixes #17582

File:
1 edited

Legend:

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

    r18068 r18178  
    384384                'orderby' => 'login',
    385385                'order' => 'ASC',
    386                 'offset' => '', 'number' => '',
     386                'offset' => '',
     387                'number' => '',
    387388                'count_total' => true,
    388389                'fields' => 'all',
     
    418419            $this->query_fields = "$wpdb->users.ID";
    419420        }
     421
     422        if ( $this->query_vars['count_total'] )
     423            $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
    420424
    421425        $this->query_from = "FROM $wpdb->users";
     
    518522            $this->query_from .= $clauses['join'];
    519523            $this->query_where .= $clauses['where'];
     524
     525            if ( 'OR' == $meta_query->relation )
     526                $this->query_fields = 'DISTINCT ' . $this->query_fields;
    520527        }
    521528
     
    547554
    548555        if ( $this->query_vars['count_total'] )
    549             $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
     556            $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
    550557
    551558        if ( !$this->results )
Note: See TracChangeset for help on using the changeset viewer.