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. git-svn-id: http://core.svn.wordpress.org/trunk@21376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fcae3978c3
commit
174dad02bc
|
@ -133,6 +133,9 @@ if ( !function_exists('get_user_by') ) :
|
||||||
* @return bool|object False on failure, WP_User object on success
|
* @return bool|object False on failure, WP_User object on success
|
||||||
*/
|
*/
|
||||||
function get_user_by( $field, $value ) {
|
function get_user_by( $field, $value ) {
|
||||||
|
if ( 'id' === $field && (int) $value && get_current_user_id() === (int) $value )
|
||||||
|
return wp_get_current_user();
|
||||||
|
|
||||||
$userdata = WP_User::get_data_by( $field, $value );
|
$userdata = WP_User::get_data_by( $field, $value );
|
||||||
|
|
||||||
if ( !$userdata )
|
if ( !$userdata )
|
||||||
|
|
Loading…
Reference in New Issue