WordPress.org

Make WordPress Core

Ticket #41762: 41762.diff

File 41762.diff, 1.4 KB (added by spacedmonkey, 4 years ago)
  • src/wp-includes/ms-load.php

     
    312312                 * If we're not dealing with one of these installations, then the important part is determining
    313313                 * the network first, because we need the network's path to identify any sites.
    314314                 */
    315                 if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
    316                         // Are there even two networks installed?
    317                         $one_network = $wpdb->get_row( "SELECT * FROM $wpdb->site LIMIT 2" ); // [sic]
    318                         if ( 1 === $wpdb->num_rows ) {
    319                                 $current_site = new WP_Network( $one_network );
    320                                 wp_cache_add( 'current_network', $current_site, 'site-options' );
    321                         } elseif ( 0 === $wpdb->num_rows ) {
    322                                 // A network not found hook should fire here.
    323                                 return false;
    324                         }
     315                // Are there even two networks installed?
     316                $network_query = new WP_Network_Query();
     317                $args          = array( 'number' => 2 );
     318                $networks      = $network_query->query( $args );
     319                if ( 1 === $network_query->found_networks ) {
     320                        $current_site = array_shift( $networks );
     321                } elseif ( 0 === $network_query->found_networks ) {
     322                        // A network not found hook should fire here.
     323                        return false;
    325324                }
    326325
     326
    327327                if ( empty( $current_site ) ) {
    328328                        $current_site = WP_Network::get_by_path( $domain, $path, 1 );
    329329                }