WordPress.org

Make WordPress Core

Changeset 41242


Ignore:
Timestamp:
08/12/2017 01:10:24 PM (11 months ago)
Author:
flixos90
Message:

Multisite: Remove references to $wpdb->siteid and use get_current_network_id() instead.

Props sathyapulse, spacedmonkey.
Fixes #41507.

Location:
trunk
Files:
8 edited

Legend:

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

    r41241 r41242  
    793793 * @since 3.1.0
    794794 *
    795  * @global wpdb $wpdb WordPress database abstraction object.
    796  *
    797795 * @param int $network_id The network ID to check.
    798796 * @return bool True if network can be edited, otherwise false.
    799797 */
    800798function can_edit_network( $network_id ) {
    801     global $wpdb;
    802 
    803     if ( $network_id == $wpdb->siteid )
     799    if ( $network_id == get_current_network_id() )
    804800        $result = true;
    805801    else
  • trunk/src/wp-includes/ms-blogs.php

    r41200 r41242  
    10921092        _deprecated_argument( __FUNCTION__, 'MU' ); // never used
    10931093
    1094     return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
     1094    return $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", get_current_network_id(), $start, $quantity ), ARRAY_A );
    10951095}
    10961096
  • trunk/src/wp-includes/ms-deprecated.php

    r41241 r41242  
    188188
    189189    global $wpdb;
    190     $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
     190    $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", get_current_network_id() ), ARRAY_A );
    191191
    192192    $blog_list = array();
     
    431431
    432432    if ( ! $domain )
    433         $network_id = $wpdb->siteid;
     433        $network_id = get_current_network_id();
    434434    else
    435435        $network_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) );
     
    447447 * @deprecated 4.6.0 Use get_sites()
    448448 * @see get_sites()
    449  *
    450  * @global wpdb $wpdb WordPress database abstraction object.
    451449 *
    452450 * @param array $args {
     
    469467 */
    470468function wp_get_sites( $args = array() ) {
    471     global $wpdb;
    472 
    473469    _deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
    474470
     
    477473
    478474    $defaults = array(
    479         'network_id' => $wpdb->siteid,
     475        'network_id' => get_current_network_id(),
    480476        'public'     => null,
    481477        'archived'   => null,
  • trunk/src/wp-includes/ms-functions.php

    r41241 r41242  
    7373        if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
    7474            foreach ( (array) $blogs as $blog_id => $blog ) {
    75                 if ( $blog->site_id != $wpdb->siteid )
     75                if ( $blog->site_id != get_current_network_id() )
    7676                    continue;
    7777                $details = get_site( $blog_id );
     
    10901090    }
    10911091
    1092     $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid );
     1092    $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, get_current_network_id() );
    10931093
    10941094    // TODO: What to do if we create a user but cannot create a blog?
  • trunk/src/wp-includes/option.php

    r41241 r41242  
    224224
    225225    if ( empty($network_id) )
    226         $network_id = $wpdb->siteid;
     226        $network_id = get_current_network_id();
    227227
    228228    $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
  • trunk/src/wp-signup.php

    r41200 r41242  
    355355 */
    356356function validate_another_blog_signup() {
    357     global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
     357    global $blogname, $blog_title, $errors, $domain, $path;
    358358    $current_user = wp_get_current_user();
    359359    if ( ! is_user_logged_in() ) {
     
    423423    $meta = apply_filters( 'add_signup_meta', $meta_defaults );
    424424
    425     $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
     425    $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() );
    426426
    427427    if ( is_wp_error( $blog_id ) ) {
  • trunk/tests/phpunit/tests/multisite/network.php

    r40612 r41242  
    190190     */
    191191    public function test_get_blog_count_on_different_network() {
    192         global $current_site, $wpdb;
    193 
    194         // switch_to_network()...
    195         $orig_network_id = $current_site->id;
    196         $orig_wpdb_network_id = $wpdb->siteid;
    197         $current_site->id = self::$different_network_id;
    198         $wpdb->siteid = self::$different_network_id;
    199         wp_update_network_site_counts();
    200         $current_site->id = $orig_network_id;
    201         $wpdb->siteid = $orig_wpdb_network_id;
     192        wp_update_network_site_counts( self::$different_network_id );
    202193
    203194        $site_count = get_blog_count( self::$different_network_id );
     
    210201     */
    211202    public function test_get_user_count_on_different_network() {
    212         global $current_site, $wpdb;
    213 
    214203        wp_update_network_user_counts();
    215204        $current_network_user_count = get_user_count();
    216205
    217         // switch_to_network()...
    218         $orig_network_id = $current_site->id;
    219         $orig_wpdb_network_id = $wpdb->siteid;
    220         $current_site->id = self::$different_network_id;
    221         $wpdb->siteid = self::$different_network_id;
    222 
    223206        // Add another user to fake the network user count to be different.
    224207        wpmu_create_user( 'user', 'pass', 'email' );
    225208
    226         wp_update_network_user_counts();
    227 
    228         // restore_current_network()...
    229         $current_site->id = $orig_network_id;
    230         $wpdb->siteid = $orig_wpdb_network_id;
     209        wp_update_network_user_counts( self::$different_network_id );
    231210
    232211        $user_count = get_user_count( self::$different_network_id );
  • trunk/tests/phpunit/tests/option/multisite.php

    r38762 r41242  
    149149     */
    150150    function test_site_notoptions() {
    151         global $wpdb;
    152         $notoptions_key = "{$wpdb->siteid}:notoptions";
     151        $network_id = get_current_network_id();
     152        $notoptions_key = "{$network_id}:notoptions";
    153153
    154154        $_notoptions = wp_cache_get( 'notoptions', 'site-options' );
Note: See TracChangeset for help on using the changeset viewer.