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
This commit is contained in:
parent
9d34db0590
commit
188902ee09
@ -265,13 +265,15 @@ class WP_Site_Query {
|
|||||||
$cache_value = array(
|
$cache_value = array(
|
||||||
'site_ids' => $site_ids,
|
'site_ids' => $site_ids,
|
||||||
'found_sites' => $this->found_sites,
|
'found_sites' => $this->found_sites,
|
||||||
'max_num_pages' => $this->max_num_pages,
|
|
||||||
);
|
);
|
||||||
wp_cache_add( $cache_key, $cache_value, 'sites' );
|
wp_cache_add( $cache_key, $cache_value, 'sites' );
|
||||||
} else {
|
} else {
|
||||||
$site_ids = $cache_value['site_ids'];
|
$site_ids = $cache_value['site_ids'];
|
||||||
$this->found_sites = $cache_value['found_sites'];
|
$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 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 );
|
$found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
|
||||||
|
|
||||||
$this->found_sites = (int) $wpdb->get_var( $found_sites_query );
|
$this->found_sites = (int) $wpdb->get_var( $found_sites_query );
|
||||||
$this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user