Make WordPress Core


Ignore:
Timestamp:
07/31/2012 05:45:38 PM (12 years ago)
Author:
nacin
Message:

Optimize get_user_by( 'id', $id ) to return wp_get_current_user() when the current user ID is requested.

Provides for a major performance improvement by preventing repeated instantiations of WP_User in the capabilities API.

see #21120.

File:
1 edited

Legend:

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

    r20691 r21376  
    134134 */
    135135function get_user_by( $field, $value ) {
     136    if ( 'id' === $field && (int) $value && get_current_user_id() === (int) $value )
     137        return wp_get_current_user();
     138
    136139    $userdata = WP_User::get_data_by( $field, $value );
    137140
Note: See TracChangeset for help on using the changeset viewer.