Make WordPress Core

Changeset 54397

Timestamp:
10/06/2022 04:36:46 AM (22 months ago)
Author:
peterwilsoncc
Message:

Users: Revert use of shared objects for current user.

Reverts [50790].

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

Location:
trunk
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r54284 r54397  
    9292     * @since 2.8.0
    9393     * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
    94      * @since 5.8.0 Returns the global `$current_user` if it's the user being fetched.
    9594     *
    9695     * @global WP_User $current_user The current user object which holds the user data.
     
    101100     */
    102101    function get_user_by( $field, $value ) {
    103         global $current_user;
    104 
    105102        $userdata = WP_User::get_data_by( $field, $value );
    106103
    107104        if ( ! $userdata ) {
    108105            return false;
    109         }
    110 
    111         if ( $current_user instanceof WP_User && $current_user->ID === (int) $userdata->ID ) {
    112             return $current_user;
    113106        }
    114107
  • trunk/src/wp-includes/user.php

    r54329 r54397  
    18741874 * @since 3.0.0
    18751875 * @since 4.4.0 'clean_user_cache' action was added.
    1876  * @since 5.8.0 Refreshes the global user instance if cleaning the user cache for the current user.
    1877  *
    1878  * @global WP_User $current_user The current user object which holds the user data.
    18791876 *
    18801877 * @param WP_User|int $user User object or ID to be cleaned from the cache
    18811878 */
    18821879function clean_user_cache( $user ) {
    1883     global $current_user;
    1884 
    18851880    if ( is_numeric( $user ) ) {
    18861881        $user = new WP_User( $user );
     
    19081903     */
    19091904    do_action( 'clean_user_cache', $user->ID, $user );
    1910 
    1911     // Refresh the global user instance if the cleaning current user.
    1912     if ( get_current_user_id() === (int) $user->ID ) {
    1913         $user_id      = (int) $user->ID;
    1914         $current_user = null;
    1915         wp_set_current_user( $user_id, '' );
    1916     }
    19171905}
    19181906
Note: See TracChangeset for help on using the changeset viewer.