WordPress.org

Make WordPress Core

Ticket #41762: 41762.2.diff

File 41762.2.diff, 1.6 KB (added by flixos90, 4 years ago)
  • src/wp-includes/ms-load.php

     
    268268 * @since 4.6.0
    269269 * @access private
    270270 *
    271  * @global wpdb       $wpdb         WordPress database abstraction object.
    272271 * @global WP_Network $current_site The current network.
    273272 * @global WP_Site    $current_blog The current site.
    274273 *
     
    281280 *                     Redirect URL if parts exist, but the request as a whole can not be fulfilled.
    282281 */
    283282function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) {
    284         global $wpdb, $current_site, $current_blog;
     283        global $current_site, $current_blog;
    285284
    286285        // If the network is defined in wp-config.php, we can simply use that.
    287286        if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
     
    314313                 */
    315314                if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
    316315                        // 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 );
     316                        $networks = get_networks( array( 'number' => 2 ) );
     317                        if ( count( $networks ) === 1 ) {
     318                                $current_site = array_shift( $networks );
    320319                                wp_cache_add( 'current_network', $current_site, 'site-options' );
    321                         } elseif ( 0 === $wpdb->num_rows ) {
     320                        } elseif ( empty( $networks ) ) {
    322321                                // A network not found hook should fire here.
    323322                                return false;
    324323                        }