mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Networks and Sites: Store main site id of a network in network options.
Instead of caching main site id an object cache, store main site id on a network options. This results in less database queries on sites without persistent object caching. Props spacedmonkey, johnjamesjacoby, peterwilsoncc, desrosj. Fixes #55802. git-svn-id: https://develop.svn.wordpress.org/trunk@54256 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -255,9 +255,8 @@ class WP_Network {
|
||||
if ( $site->domain === $this->domain && $site->path === $this->path ) {
|
||||
$main_site_id = (int) $site->id;
|
||||
} else {
|
||||
$cache_key = 'network:' . $this->id . ':main_site';
|
||||
|
||||
$main_site_id = wp_cache_get( $cache_key, 'site-options' );
|
||||
$main_site_id = get_network_option( $this->id, 'main_site' );
|
||||
if ( false === $main_site_id ) {
|
||||
$_sites = get_sites(
|
||||
array(
|
||||
@@ -270,7 +269,7 @@ class WP_Network {
|
||||
);
|
||||
$main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0;
|
||||
|
||||
wp_cache_add( $cache_key, $main_site_id, 'site-options' );
|
||||
update_network_option( $this->id, 'main_site', $main_site_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user