[wp-trac] [WordPress Trac] #21120: Optimize get_user_by()
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 6 23:27:16 UTC 2012
#21120: Optimize get_user_by()
------------------------------------+------------------------------
Reporter: kurtpayne | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Performance | Version:
Severity: normal | Resolution:
Keywords: dev-feedback has-patch |
------------------------------------+------------------------------
Comment (by scribu):
Here's the workflow with 21120.2.patch:
First call:
{{{
get_user_by()
-> WP_User::get_data_by()
-> wp_cache_get( $user_id, 'users' ) // gets the raw userdata
-> wp_cache_get( $user_id, 'users' ) // gets the raw userdata
-> wp_cache_set( $user_id, $full_user, 'users' )
}}}
Subsequent calls:
{{{
get_user_by()
-> WP_User::get_data_by( ... )
-> wp_cache_get( $user_id, 'users' ) // gets the full userdata
-> wp_cache_get( $user_id, 'users' ) // gets the full userdata
}}}
That doesn't seem sane to me. At a minimum, you could eliminate the
additional wp_cache_get() check from get_user_by().
The real question is why is get_user_by() called so many times?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21120#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list