WordPress.org

Make WordPress Core

Ticket #41684: 41684-5.patch

File 41684-5.patch, 7.7 KB (added by bnap00, 3 years ago)
  • 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

     
    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;
    2017
    21         update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
     18        update_blog_details( get_current_blog_id(), array('last_updated' => current_time('mysql', true)) );
    2219        /**
    2320         * Fires after the blog details are updated.
    2421         *
     
    2623         *
    2724         * @param int $blog_id Site ID.
    2825         */
    29         do_action( 'wpmu_blog_updated', $wpdb->blogid );
     26        do_action( 'wpmu_blog_updated', get_current_blog_id() );
    3027}
    3128
    3229/**
  • 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;
    2219
    2320        // This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
    2421        add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
     
    3330        // Note, the main site in a post-MU network uses wp-content/uploads.
    3431        // This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
    3532        if ( ! defined( 'UPLOADS' ) ) {
    36                 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
     33                define( 'UPLOADS', UPLOADBLOGSDIR . '/' . get_current_blog_id() . '/files/' );
    3734
    3835                // Uploads dir relative to ABSPATH
    3936                if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
    40                         define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
     37                        define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . get_current_blog_id() . '/files/' );
    4138        }
    4239}
    4340
  • 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
    4845        if ( !is_multisite() )
    49                 return $blogs[$wpdb->blogid];
     46                return $blogs[get_current_blog_id()];
    5047
    5148        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    5249        $first_blog = current($blogs);
     
    22162213
    22172214        $current_user = wp_get_current_user();
    22182215        if ( $blog_id == 0 ) {
    2219                 $blog_id = $wpdb->blogid;
     2216                $blog_id = get_current_blog_id();
    22202217        }
    22212218        $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
    22222219
  • tests/phpunit/tests/multisite/site.php

     
    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 ) {