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-blogs.php

    r41625 r41661  
    1313 *
    1414 * @since MU (3.0.0)
    15  *
    16  * @global wpdb $wpdb WordPress database abstraction object.
    1715 */
    1816function wpmu_update_blogs_date() {
    19     global $wpdb;
    20 
    21     update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
     17    $site_id = get_current_blog_id();
     18
     19    update_blog_details( $site_id, array( 'last_updated' => current_time( 'mysql', true ) ) );
    2220    /**
    2321     * Fires after the blog details are updated.
     
    2725     * @param int $blog_id Site ID.
    2826     */
    29     do_action( 'wpmu_blog_updated', $wpdb->blogid );
     27    do_action( 'wpmu_blog_updated', $site_id );
    3028}
    3129
Note: See TracChangeset for help on using the changeset viewer.