599 | | if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { |
600 | | $this->results = $wpdb->get_results( $this->request ); |
601 | | } else { |
602 | | $this->results = $wpdb->get_col( $this->request ); |
603 | | } |
| 599 | // Get |
| 600 | $cache_key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->fill_query_vars( array() ) ) ) ) ); |
| 601 | $last_changed = wp_cache_get_last_changed( 'users' ); |
| 602 | $cache_key = "get_users:{$cache_key}:{$last_changed}"; |
| 603 | $cache_value = wp_cache_get( $cache_key, 'users' ); |
605 | | /** |
606 | | * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance. |
607 | | * |
608 | | * @since 3.2.0 |
609 | | * |
610 | | * @global wpdb $wpdb WordPress database abstraction object. |
611 | | * |
612 | | * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query. |
613 | | */ |
614 | | if ( isset( $qv['count_total'] ) && $qv['count_total'] ) |
615 | | $this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); |
| 605 | if ( false === $cache_value ) { |
| 606 | if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { |
| 607 | $this->results = $wpdb->get_results( $this->request ); |
| 608 | } else { |
| 609 | $this->results = $wpdb->get_col( $this->request ); |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance. |
| 614 | * |
| 615 | * @since 3.2.0 |
| 616 | * |
| 617 | * @global wpdb $wpdb WordPress database abstraction object. |
| 618 | * |
| 619 | * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query. |
| 620 | */ |
| 621 | if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
| 622 | $this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); |
| 623 | } |
| 624 | |
| 625 | // Setup array to cache |
| 626 | $cache_value = array( |
| 627 | 'users' => $this->results, |
| 628 | 'found_users' => (int) $this->total_users, |
| 629 | ); |
| 630 | |
| 631 | // Add results to cache to cache |
| 632 | wp_cache_add( $cache_key, $cache_value, 'users' ); |
| 633 | } else { |
| 634 | $this->results = $cache_value['users']; |
| 635 | $this->total_users = (int) $cache_value['found_users']; |
| 636 | } |