From 65a90ba4965cddaa9122822e2bf25f62967eed37 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 7 Jul 2016 15:51:58 +0000 Subject: [PATCH] Multisite: Don't store `max_num_pages` in `WP_Network_Query` query cache. This value can be easily calculated with available data. Props spacedmonkey. Fixes #32504. git-svn-id: https://develop.svn.wordpress.org/trunk@38003 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-network-query.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index ec4d97cd4d..9390657894 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -229,13 +229,15 @@ class WP_Network_Query { $cache_value = array( 'network_ids' => $network_ids, 'found_networks' => $this->found_networks, - 'max_num_pages' => $this->max_num_pages, ); wp_cache_add( $cache_key, $cache_value, 'networks' ); } else { $network_ids = $cache_value['network_ids']; $this->found_networks = $cache_value['found_networks']; - $this->max_num_pages = $cache_value['max_num_pages']; + } + + if ( $this->found_networks && $this->query_vars['number'] ) { + $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] ); } // If querying for a count only, there's nothing more to do. @@ -477,7 +479,6 @@ class WP_Network_Query { $found_networks_query = apply_filters( 'found_networks_query', 'SELECT FOUND_ROWS()', $this ); $this->found_networks = (int) $wpdb->get_var( $found_networks_query ); - $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] ); } }