WordPress.org

Make WordPress Core

Ticket #39090: 39090.patch

File 39090.patch, 1.0 KB (added by rodrigosprimo, 4 years ago)
  • src/wp-includes/class-wp-user-query.php

    diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php
    index 0c3e105..f5f4dc4 100644
    a b class WP_User_Query { 
    596596
    597597                $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
    598598
    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 );
     599                $cache_key = 'user_query_' . md5( $this->request );
     600                $this->results = wp_cache_get( $cache_key, 'users' );
     601
     602                if ( ! $this->results ) {
     603                        if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
     604                                $this->results = $wpdb->get_results( $this->request );
     605                        } else {
     606                                $this->results = $wpdb->get_col( $this->request );
     607                        }
     608
     609                        wp_cache_add( $cache_key, $this->results, 'users' );
    603610                }
    604611
    605612                /**