Make WordPress Core

Ticket #17582: 17582.4.diff

File 17582.4.diff, 1.5 KB (added by scribu, 14 years ago)
  • wp-includes/user.php

     
    383383                                'search' => '',
    384384                                'orderby' => 'login',
    385385                                'order' => 'ASC',
    386                                 'offset' => '', 'number' => '',
     386                                'offset' => '',
     387                                'number' => '',
    387388                                'count_total' => true,
    388389                                'fields' => 'all',
    389390                                'who' => ''
     
    418419                        $this->query_fields = "$wpdb->users.ID";
    419420                }
    420421
     422                if ( $this->query_vars['count_total'] ) {
     423                        $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
     424                }
     425
    421426                $this->query_from = "FROM $wpdb->users";
    422427                $this->query_where = "WHERE 1=1";
    423428
     
    517522                        $clauses = $meta_query->get_sql( 'user', $wpdb->users, 'ID', $this );
    518523                        $this->query_from .= $clauses['join'];
    519524                        $this->query_where .= $clauses['where'];
     525
     526                        if ( 'OR' == $meta_query->relation ) {
     527                                $this->query_fields = 'DISTINCT ' . $this->query_fields;
     528                        }
    520529                }
    521530
    522531                if ( !empty( $qv['include'] ) ) {
     
    545554                        $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
    546555                }
    547556
    548                 if ( $this->query_vars['count_total'] )
    549                         $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
     557                if ( $this->query_vars['count_total'] ) {
     558                        $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
     559                }
    550560
    551561                if ( !$this->results )
    552562                        return;