[wp-trac] [WordPress Trac] #21120: Optimize get_user_by()
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 6 21:46:02 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 kurtpayne):
Replying to [comment:11 scribu]:
> Actually, {{{WP_User::init()}}} is also called in
{{{WP_User::__construct()}}} if you pass an id or a login.
You're right. In `WP_User_Query::query`, though, the results of the query
are cached, but not the results of `WP_User::__construct` called for each
user in the query.
Perhaps this should be an additional optimization?
Here's the code in question from `WP_User_Query::query`
{{{
if ( 'all_with_meta' == $this->query_vars['fields'] ) {
cache_users( $this->results );
$r = array();
foreach ( $this->results as $userid )
$r[ $userid ] = new WP_User( $userid, '',
$this->query_vars['blog_id'] );
$this->results = $r;
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21120#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list