mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
Multisite: Use get_networks()
in get_main_network_id()
.
The manual query for the main network ID can now be replaced with a cached `get_networks()` query. This allows us to eliminate the `primary_network_id` cache key entirely. Props spacedmonkey. Fixes #37218. Built from https://develop.svn.wordpress.org/trunk@38632 git-svn-id: http://core.svn.wordpress.org/trunk@38575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
02c8bd1909
commit
63664c1282
@ -4353,13 +4353,9 @@ function is_main_network( $network_id = null ) {
|
|||||||
*
|
*
|
||||||
* @since 4.3.0
|
* @since 4.3.0
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb WordPress database abstraction object.
|
|
||||||
*
|
|
||||||
* @return int The ID of the main network.
|
* @return int The ID of the main network.
|
||||||
*/
|
*/
|
||||||
function get_main_network_id() {
|
function get_main_network_id() {
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if ( ! is_multisite() ) {
|
if ( ! is_multisite() ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -4372,12 +4368,8 @@ function get_main_network_id() {
|
|||||||
// If the current network has an ID of 1, assume it is the main network.
|
// If the current network has an ID of 1, assume it is the main network.
|
||||||
$main_network_id = 1;
|
$main_network_id = 1;
|
||||||
} else {
|
} else {
|
||||||
$main_network_id = wp_cache_get( 'primary_network_id', 'site-options' );
|
$_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) );
|
||||||
|
$main_network_id = array_shift( $_networks );
|
||||||
if ( false === $main_network_id ) {
|
|
||||||
$main_network_id = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1" );
|
|
||||||
wp_cache_add( 'primary_network_id', $main_network_id, 'site-options' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-alpha-38631';
|
$wp_version = '4.7-alpha-38632';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user