From 188902ee0957434ac72dd31f641bc30dc054a9a4 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 7 Jul 2016 15:31:45 +0000 Subject: [PATCH] Multisite: Don't store `max_num_pages` in `WP_Site_Query` query cache. This value can be easily calculated with available data. Props spacedmonkey. Fixes #35791. git-svn-id: https://develop.svn.wordpress.org/trunk@38002 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-site-query.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index 94a179a979..44b54f0710 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -265,13 +265,15 @@ class WP_Site_Query { $cache_value = array( 'site_ids' => $site_ids, 'found_sites' => $this->found_sites, - 'max_num_pages' => $this->max_num_pages, ); wp_cache_add( $cache_key, $cache_value, 'sites' ); } else { $site_ids = $cache_value['site_ids']; $this->found_sites = $cache_value['found_sites']; - $this->max_num_pages = $cache_value['max_num_pages']; + } + + if ( $this->found_sites && $this->query_vars['number'] ) { + $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] ); } // If querying for a count only, there's nothing more to do. @@ -588,7 +590,6 @@ class WP_Site_Query { $found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this ); $this->found_sites = (int) $wpdb->get_var( $found_sites_query ); - $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] ); } }