WordPress.org

Make WordPress Core

Ticket #41684: 41684.2.diff

File 41684.2.diff, 6.9 KB (added by jeremyfelt, 3 years ago)
  • src/wp-admin/includes/upgrade.php

     
    12571257                        }
    12581258                        $start += 20;
    12591259                }
    1260                 refresh_blog_details( $wpdb->blogid );
     1260                refresh_blog_details();
    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

     
    1212 * Update the last_updated field for the current site.
    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;
     17        $site_id = get_current_blog_id();
    2018
    21         update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
     19        update_blog_details( $site_id, array( 'last_updated' => current_time( 'mysql', true ) ) );
    2220        /**
    2321         * Fires after the blog details are updated.
    2422         *
     
    2624         *
    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
    3230/**
  • src/wp-includes/ms-default-constants.php

     
    1414 * wp-includes/ms-files.php (wp-content/blogs.php in MU).
    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' );
    2521
     
    3329        // Note, the main site in a post-MU network uses wp-content/uploads.
    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}
    4341
  • src/wp-includes/ms-functions.php

     
    3434 *
    3535 * @since MU (3.0.0) 1.0
    3636 *
    37  * @global wpdb $wpdb WordPress database abstraction object.
    38  *
    3937 * @param int $user_id The unique ID of the user
    4038 * @return WP_Site|void The blog object
    4139 */
    4240function get_active_blog_for_user( $user_id ) {
    43         global $wpdb;
    4441        $blogs = get_blogs_of_user( $user_id );
    4542        if ( empty( $blogs ) )
    4643                return;
    4744
    48         if ( !is_multisite() )
    49                 return $blogs[$wpdb->blogid];
     45        if ( ! is_multisite() ) {
     46                return $blogs[ get_current_blog_id() ];
     47        }
    5048
    5149        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    5250        $first_blog = current($blogs);
     
    22192217
    22202218        $current_user = wp_get_current_user();
    22212219        if ( $blog_id == 0 ) {
    2222                 $blog_id = $wpdb->blogid;
     2220                $blog_id = get_current_blog_id();
    22232221        }
    22242222        $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
    22252223
  • tests/phpunit/tests/multisite/site.php

     
    363363                wpmu_update_blogs_date();
    364364
    365365                // compare the update time with the current time, allow delta < 2
    366                 $blog = get_site( $wpdb->blogid );
     366                $blog = get_site( get_current_blog_id() );
    367367                $current_time = time();
    368368                $time_difference = $current_time - strtotime( $blog->last_updated );
    369369                $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
     
    149149                $this->assertFalse( is_user_member_of_blog() );
    150150
    151151                wp_set_current_user( $user1_id );
     152                $site_id = get_current_blog_id();
    152153
    153154                $this->assertTrue( is_user_member_of_blog() );
    154155                $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
    155                 $this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
     156                $this->assertTrue( is_user_member_of_blog( 0, $site_id ) );
    156157                $this->assertTrue( is_user_member_of_blog( $user1_id ) );
    157                 $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
     158                $this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
    158159
    159160                $blog_ids = self::factory()->blog->create_many( 1 );
    160161                foreach ( $blog_ids as $blog_id ) {