WordPress.org

Make WordPress Core

Ticket #37218: 37218.4.diff

File 37218.4.diff, 1.0 KB (added by jeremyfelt, 3 years ago)
  • src/wp-includes/functions.php

     
    43504350 *
    43514351 * @since 4.3.0
    43524352 *
    4353  * @global wpdb $wpdb WordPress database abstraction object.
    4354  *
    43554353 * @return int The ID of the main network.
    43564354 */
    43574355function get_main_network_id() {
    4358         global $wpdb;
    43594356
    43604357        if ( ! is_multisite() ) {
    43614358                return 1;
     
    43694366                // If the current network has an ID of 1, assume it is the main network.
    43704367                $main_network_id = 1;
    43714368        } else {
    4372                 $main_network_id = wp_cache_get( 'primary_network_id', 'site-options' );
    4373 
    4374                 if ( false === $main_network_id ) {
    4375                         $main_network_id = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1" );
    4376                         wp_cache_add( 'primary_network_id', $main_network_id, 'site-options' );
    4377                 }
     4369                $_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) );
     4370                $main_network_id = array_shift( $_networks );
    43784371        }
    43794372
    43804373        /**