Users: Revert use of shared objects for current user.

Reverts [50790].

Props oztaser, ravipatel, dd32, costdev, SergeyBiryukov, tykoted, cu121, xknown.
Fixes #54984.



git-svn-id: https://develop.svn.wordpress.org/trunk@54397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2022-10-06 04:36:46 +00:00
parent aac3784618
commit e5a0d1364d
3 changed files with 0 additions and 43 deletions

View File

@@ -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 );