Make WordPress Core


Ignore:
Timestamp:
10/02/2017 01:43:48 AM (7 years ago)
Author:
jeremyfelt
Message:

Multisite: Use get_current_blog_id() instead of $wpdb->blogid.

get_current_blog_id() is more appropriate for determining the ID of the current site in most cases. This eliminates the need for the global $wpdb in several functions and is better than the implicit global used in admin pages.

Props bnap00, spacedmonkey.
Fixes #41684.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-default-constants.php

    r38814 r41661  
    1515 *
    1616 * @since 3.0.0
    17  *
    18  * @global wpdb $wpdb WordPress database abstraction object.
    1917 */
    2018function ms_upload_constants() {
    21     global $wpdb;
    22 
    2319    // This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
    2420    add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
     
    3430    // This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
    3531    if ( ! defined( 'UPLOADS' ) ) {
    36         define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
     32        $site_id = get_current_blog_id();
     33
     34        define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' );
    3735
    3836        // Uploads dir relative to ABSPATH
    3937        if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
    40             define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
     38            define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' );
    4139    }
    4240}
Note: See TracChangeset for help on using the changeset viewer.