From 767dea88eb3bdb3fefb0bd9a552bb0d3ded2b14f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 25 Dec 2024 18:31:23 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `remove_user_from_blog()`. Follow-up to [https://mu.trac.wordpress.org/changeset/543 mu:543]. Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov. See #62279, #62283. Built from https://develop.svn.wordpress.org/trunk@59561 git-svn-id: http://core.svn.wordpress.org/trunk@58947 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 7cfb403e9e..9f1889fda6 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -230,8 +230,10 @@ function add_user_to_blog( $blog_id, $user_id, $role ) { function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) { global $wpdb; - switch_to_blog( $blog_id ); $user_id = (int) $user_id; + $blog_id = (int) $blog_id; + + switch_to_blog( $blog_id ); /** * Fires before a user is removed from a site. @@ -249,13 +251,13 @@ function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) { * If being removed from the primary blog, set a new primary * if the user is assigned to multiple blogs. */ - $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); - if ( $primary_blog == $blog_id ) { + $primary_blog = (int) get_user_meta( $user_id, 'primary_blog', true ); + if ( $primary_blog === $blog_id ) { $new_id = ''; $new_domain = ''; $blogs = get_blogs_of_user( $user_id ); foreach ( (array) $blogs as $blog ) { - if ( $blog->userblog_id == $blog_id ) { + if ( $blog->userblog_id === $blog_id ) { continue; } $new_id = $blog->userblog_id; diff --git a/wp-includes/version.php b/wp-includes/version.php index 86b04d1e5c..709a4dbafb 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59560'; +$wp_version = '6.8-alpha-59561'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.