WordPress.org

Make WordPress Core

Ticket #41684: 41684-2.patch

File 41684-2.patch, 8.6 KB (added by bnap00, 3 years ago)
  • src/wp-admin/includes/schema.php

     
    3838
    3939        $charset_collate = $wpdb->get_charset_collate();
    4040
    41         if ( $blog_id && $blog_id != $wpdb->blogid )
     41        if ( $blog_id && $blog_id != get_current_blog_id() )
    4242                $old_blog_id = $wpdb->set_blog_id( $blog_id );
    4343
    4444        // Engage multisite if in the middle of turning it on from network.php.
  • src/wp-admin/includes/upgrade.php

     
    433433        wp_cache_flush();
    434434
    435435        if ( is_multisite() ) {
    436                 if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
    437                         $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
     436                if ( $wpdb->get_row( $wpdb->prepare( 'SELECT blog_id FROM %s WHERE blog_id = %d', $wpdb->blog_versions, get_current_blog_id() ) ) );
     437                        $wpdb->query( $wpdb->prepare( 'UPDATE %s SET db_version = %d WHERE blog_id = %d', $wpdb->blog_versions, $wp_db_version, get_current_blog_id() ) );
    438438                else
    439                         $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
     439                        $wpdb->query( $wpdb->prepare( 'INSERT INTO %s ( `blog_id` , `db_version` , `last_updated` ) VALUES ( %d, %d, %s);', get_current_blog_id(), $wpdb->blog_versions, $wp_db_version, NOW() ) );
    440440        }
    441441
    442442        /**
     
    12571257                        }
    12581258                        $start += 20;
    12591259                }
    1260                 refresh_blog_details( $wpdb->blogid );
     1260                refresh_blog_details( get_current_blog_id() );
    12611261        }
    12621262}
    12631263
  • src/wp-admin/ms-delete-site.php

     
    1717
    1818if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
    1919        if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) {
    20                 wpmu_delete_blog( $wpdb->blogid );
     20                wpmu_delete_blog( get_current_blog_id() );
    2121                wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), get_network()->site_name ) );
    2222        } else {
    2323                wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
  • src/wp-admin/user-new.php

     
    156156                                add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
    157157                                add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
    158158                        }
    159                         wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) );
     159                        wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => get_current_blog_id(), 'new_role' => $_REQUEST['role'] ) );
    160160                        if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) {
    161161                                $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
    162162                                $new_user = wpmu_activate_signup( $key );
  • src/wp-includes/ms-blogs.php

     
    1616 * @global wpdb $wpdb WordPress database abstraction object.
    1717 */
    1818function wpmu_update_blogs_date() {
    19         global $wpdb;
    2019
    21         update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
     20        update_blog_details( get_current_blog_id(), array('last_updated' => current_time('mysql', true)) );
    2221        /**
    2322         * Fires after the blog details are updated.
    2423         *
     
    2625         *
    2726         * @param int $blog_id Site ID.
    2827         */
    29         do_action( 'wpmu_blog_updated', $wpdb->blogid );
     28        do_action( 'wpmu_blog_updated', get_current_blog_id() );
    3029}
    3130
    3231/**
  • src/wp-includes/ms-default-constants.php

     
    3333        // Note, the main site in a post-MU network uses wp-content/uploads.
    3434        // This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
    3535        if ( ! defined( 'UPLOADS' ) ) {
    36                 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
     36                define( 'UPLOADS', UPLOADBLOGSDIR . '/' . get_current_blog_id() . '/files/' );
    3737
    3838                // Uploads dir relative to ABSPATH
    3939                if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
    40                         define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
     40                        define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . get_current_blog_id() . '/files/' );
    4141        }
    4242}
    4343
  • src/wp-includes/ms-functions.php

     
    4646                return;
    4747
    4848        if ( !is_multisite() )
    49                 return $blogs[$wpdb->blogid];
     49                return $blogs[get_current_blog_id()];
    5050
    5151        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    5252        $first_blog = current($blogs);
     
    22162216
    22172217        $current_user = wp_get_current_user();
    22182218        if ( $blog_id == 0 ) {
    2219                 $blog_id = $wpdb->blogid;
     2219                $blog_id = get_current_blog_id();
    22202220        }
    22212221        $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
    22222222
  • tests/phpunit/tests/multisite/site.php

     
    6262                $this->assertNotEquals( $cap_key, wp_get_current_user()->cap_key );
    6363                $this->assertEquals( array( $current_blog_id ), $_wp_switched_stack );
    6464                $this->assertTrue( ms_is_switched() );
    65                 $this->assertEquals( $blog_id, $wpdb->blogid );
     65                $this->assertEquals( $blog_id, get_current_blog_id() );
    6666                $this->assertFalse( wp_cache_get( 'switch-test', 'switch-test' ) );
    6767                wp_cache_set( 'switch-test', $blog_id, 'switch-test' );
    6868                $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
     
    7070                switch_to_blog( $blog_id );
    7171                $this->assertEquals( array( $current_blog_id, $blog_id ), $_wp_switched_stack );
    7272                $this->assertTrue( ms_is_switched() );
    73                 $this->assertEquals( $blog_id, $wpdb->blogid );
     73                $this->assertEquals( $blog_id, get_current_blog_id() );
    7474                $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
    7575
    7676                restore_current_blog();
    7777                $this->assertEquals( array( $current_blog_id ), $_wp_switched_stack );
    7878                $this->assertTrue( ms_is_switched() );
    79                 $this->assertEquals( $blog_id, $wpdb->blogid );
     79                $this->assertEquals( $blog_id, get_current_blog_id() );
    8080                $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
    8181
    8282                restore_current_blog();
     
    348348                wpmu_update_blogs_date();
    349349
    350350                // compare the update time with the current time, allow delta < 2
    351                 $blog = get_site( $wpdb->blogid );
     351                $blog = get_site( get_current_blog_id() );
    352352                $current_time = time();
    353353                $time_difference = $current_time - strtotime( $blog->last_updated );
    354354                $this->assertLessThan( 2, $time_difference );
  • tests/phpunit/tests/user/multisite.php

     
    120120                wp_set_current_user( $user1_id );
    121121
    122122                $this->assertTrue( is_blog_user() );
    123                 $this->assertTrue( is_blog_user( $wpdb->blogid ) );
     123                $this->assertTrue( is_blog_user( get_current_blog_id() ) );
    124124
    125125                $blog_ids = array();
    126126
     
    152152
    153153                $this->assertTrue( is_user_member_of_blog() );
    154154                $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
    155                 $this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
     155                $this->assertTrue( is_user_member_of_blog( 0, get_current_blog_id() ) );
    156156                $this->assertTrue( is_user_member_of_blog( $user1_id ) );
    157                 $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
     157                $this->assertTrue( is_user_member_of_blog( $user1_id, get_current_blog_id() ) );
    158158
    159159                $blog_ids = self::factory()->blog->create_many( 1 );
    160160                foreach ( $blog_ids as $blog_id ) {