WordPress.org

Make WordPress Core

Ticket #21120: 21120.2.patch

File 21120.2.patch, 497 bytes (added by kurtpayne, 3 years ago)

Use wp_cache_get and wp_cache_set

  • wp-includes/pluggable.php

    diff --git wp-includes/pluggable.php wp-includes/pluggable.php
    index ac308a9..464c5f9
    function get_user_by( $field, $value ) { 
    138138        if ( !$userdata ) 
    139139                return false; 
    140140 
     141        $user = wp_cache_get( $userdata->ID, 'users' ); 
     142 
     143        if ( !empty( $user ) && !empty( $user->caps ) ) 
     144                return $user; 
     145 
    141146        $user = new WP_User; 
    142147        $user->init( $userdata ); 
    143148 
     149        wp_cache_set( $userdata->ID, $user, 'users' ); 
    144150        return $user; 
    145151} 
    146152endif;