Index: src/wp-includes/class-wp-site-query.php =================================================================== --- src/wp-includes/class-wp-site-query.php (revision 37899) +++ src/wp-includes/class-wp-site-query.php (working copy) @@ -264,16 +264,18 @@ $cache_value = array( 'site_ids' => $site_ids, - 'found_sites' => $this->found_sites, - 'max_num_pages' => $this->max_num_pages, + 'found_sites' => $this->found_sites ); 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. if ( $this->query_vars['count'] ) { // $site_ids is actually a count in this case. @@ -588,7 +590,6 @@ $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'] ); } }