Make WordPress Core

Ticket #35791: 35791-dontcache-max_num_pages.diff

File 35791-dontcache-max_num_pages.diff, 1.2 KB (added by spacedmonkey, 9 years ago)
  • src/wp-includes/class-wp-site-query.php

     
    264264
    265265                        $cache_value = array(
    266266                                'site_ids' => $site_ids,
    267                                 'found_sites' => $this->found_sites,
    268                                 'max_num_pages' => $this->max_num_pages,
     267                                'found_sites' => $this->found_sites
    269268                        );
    270269                        wp_cache_add( $cache_key, $cache_value, 'sites' );
    271270                } else {
    272271                        $site_ids = $cache_value['site_ids'];
    273272                        $this->found_sites = $cache_value['found_sites'];
    274                         $this->max_num_pages = $cache_value['max_num_pages'];
    275273                }
    276274
     275                if ( $this->found_sites && $this->query_vars['number'] ) {
     276                        $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
     277                }
     278
    277279                // If querying for a count only, there's nothing more to do.
    278280                if ( $this->query_vars['count'] ) {
    279281                        // $site_ids is actually a count in this case.
     
    588590                        $found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
    589591
    590592                        $this->found_sites = (int) $wpdb->get_var( $found_sites_query );
    591                         $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
    592593                }
    593594        }
    594595