[wp-trac] [WordPress Trac] #13048: WP_Query gets the user ID for author archives twice

WordPress Trac wp-trac at lists.automattic.com
Mon Apr 19 10:47:10 UTC 2010


#13048: WP_Query gets the user ID for author archives twice
---------------------------+------------------------------------------------
 Reporter:  simonwheatley  |       Owner:  ryan      
     Type:  defect (bug)   |      Status:  new       
 Priority:  normal         |   Milestone:  Unassigned
Component:  Query          |     Version:            
 Severity:  minor          |    Keywords:            
---------------------------+------------------------------------------------

Old description:

> Currently WP_Query->get_posts does this:
>
> ```                     $q['author'] = $wpdb->get_var("SELECT ID FROM
> $wpdb->users WHERE user_nicename='".$q['author_name']."'");
>                         $q['author'] = get_user_by('slug',
> $q['author_name']);
> ```
>
> Which potentially hits the DB twice for the same info. Looks like an old
> bit of functionality got left in when the get_user_by call was added.
> Would be better if it went like this:
>
> ```                     $q['author'] = get_user_by('slug',
> $q['author_name']);
> ```

New description:

 Currently WP_Query->get_posts does this:

 {{{
                         $q['author'] = $wpdb->get_var("SELECT ID FROM
 $wpdb->users WHERE user_nicename='".$q['author_name']."'");
                         $q['author'] = get_user_by('slug',
 $q['author_name']);
 }}}

 Which potentially hits the DB twice for the same info. Looks like an old
 bit of functionality got left in when the get_user_by call was added.
 Would be better if it went like this:

 {{{
                         $q['author'] = get_user_by('slug',
 $q['author_name']);
 }}}

--

Comment(by dd32):

 fixed the code in the desc.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13048#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list