From b879d0435401b8833bae66483895ffe189e5d35a Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 6 Oct 2022 04:38:14 +0000 Subject: [PATCH] Users: Revert use of shared objects for current user. Reverts [50790]. Props oztaser, ravipatel, dd32, costdev, SergeyBiryukov, tykoted, cu121, xknown. Fixes #54984. Built from https://develop.svn.wordpress.org/trunk@54397 git-svn-id: http://core.svn.wordpress.org/trunk@53956 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 7 ------- wp-includes/user.php | 12 ------------ wp-includes/version.php | 2 +- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index ea0482b547..5d65e53f8b 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -91,7 +91,6 @@ if ( ! function_exists( 'get_user_by' ) ) : * * @since 2.8.0 * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter. - * @since 5.8.0 Returns the global `$current_user` if it's the user being fetched. * * @global WP_User $current_user The current user object which holds the user data. * @@ -100,18 +99,12 @@ if ( ! function_exists( 'get_user_by' ) ) : * @return WP_User|false WP_User object on success, false on failure. */ function get_user_by( $field, $value ) { - global $current_user; - $userdata = WP_User::get_data_by( $field, $value ); if ( ! $userdata ) { return false; } - if ( $current_user instanceof WP_User && $current_user->ID === (int) $userdata->ID ) { - return $current_user; - } - $user = new WP_User; $user->init( $userdata ); diff --git a/wp-includes/user.php b/wp-includes/user.php index 499fd9c83a..ac6c0cc01b 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1873,15 +1873,10 @@ function update_user_caches( $user ) { * * @since 3.0.0 * @since 4.4.0 'clean_user_cache' action was added. - * @since 5.8.0 Refreshes the global user instance if cleaning the user cache for the current user. - * - * @global WP_User $current_user The current user object which holds the user data. * * @param WP_User|int $user User object or ID to be cleaned from the cache */ function clean_user_cache( $user ) { - global $current_user; - if ( is_numeric( $user ) ) { $user = new WP_User( $user ); } @@ -1907,13 +1902,6 @@ function clean_user_cache( $user ) { * @param WP_User $user User object. */ do_action( 'clean_user_cache', $user->ID, $user ); - - // Refresh the global user instance if the cleaning current user. - if ( get_current_user_id() === (int) $user->ID ) { - $user_id = (int) $user->ID; - $current_user = null; - wp_set_current_user( $user_id, '' ); - } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 9c4894b5bc..e154003dc4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54396'; +$wp_version = '6.1-beta3-54397'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.