WordPress.org

Make WordPress Core

Ticket #21459: 21459-no-switched.diff

File 21459-no-switched.diff, 2.7 KB (added by ryan, 3 years ago)
  • wp-includes/functions.php

     
    14321432 * @return array See above for description. 
    14331433 */ 
    14341434function wp_upload_dir( $time = null ) { 
    1435         global $_wp_switched; 
    14361435        $siteurl = get_option( 'siteurl' ); 
    14371436        $upload_path = get_option( 'upload_path' ); 
    14381437        $upload_path = trim($upload_path); 
     
    14561455                        $url = trailingslashit( $siteurl ) . $upload_path; 
    14571456        } 
    14581457 
    1459         if ( defined('UPLOADS') && ! $main_override && ! $_wp_switched ) { 
     1458        if ( defined('UPLOADS') && ! $main_override && ! ms_is_switched() ) { 
    14601459                $dir = ABSPATH . UPLOADS; 
    14611460                $url = trailingslashit( $siteurl ) . UPLOADS; 
    14621461        } 
    14631462 
    1464         if ( is_multisite() && ! $main_override && ! $_wp_switched  ) { 
     1463        if ( is_multisite() && ! $main_override && ! ms_is_switched()  ) { 
    14651464                if ( defined( 'BLOGUPLOADDIR' ) ) 
    14661465                        $dir = untrailingslashit(BLOGUPLOADDIR); 
    14671466                $url = str_replace( UPLOADS, 'files', $url ); 
  • wp-includes/ms-blogs.php

     
    462462        * the extra unnecessary work */ 
    463463        if ( $new_blog == $GLOBALS['blog_id'] ) { 
    464464                do_action( 'switch_blog', $new_blog, $new_blog ); 
    465                 $GLOBALS['_wp_switched'] = true; 
    466465                return true; 
    467466        } 
    468467 
     
    499498        } 
    500499 
    501500        do_action( 'switch_blog', $new_blog, $prev_blog_id ); 
    502         $GLOBALS['_wp_switched'] = true; 
    503501 
    504502        return true; 
    505503} 
     
    515513function restore_current_blog() { 
    516514        global $wpdb, $wp_roles; 
    517515 
    518         if ( ! $GLOBALS['_wp_switched'] ) 
     516        if ( empty( $GLOBALS['_wp_switched_stack'] ) ) 
    519517                return false; 
    520518 
    521519        $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); 
    522520 
    523521        if ( $GLOBALS['blog_id'] == $blog ) { 
    524522                do_action( 'switch_blog', $blog, $blog ); 
    525                 // If we still have items in the switched stack, consider ourselves still 'switched' 
    526                 $GLOBALS['_wp_switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); 
    527523                return true; 
    528524        } 
    529525 
     
    575571 * @return bool True if switched, false otherwise. 
    576572 */ 
    577573function ms_is_switched() { 
    578         return $GLOBALS['_wp_switched']; 
     574        return ! empty( $GLOBALS['_wp_switched_stack'] ); 
    579575} 
    580576 
    581577/** 
  • wp-includes/ms-settings.php

     
    127127$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); 
    128128$table_prefix = $wpdb->get_blog_prefix(); 
    129129$_wp_switched_stack = array(); 
    130 $_wp_switched = false; 
    131130 
    132131// need to init cache again after blog_id is set 
    133132wp_start_object_cache();