[wp-trac] [WordPress Trac] #21120: Optimize get_user_by()

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 9 18:16:34 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:15 scribu]:
 > The real question is why is get_user_by() called so many times?

 {{{
 get_user_by:
  - called 2 times from wp_validate_auth_cookie
    - called 1 time from get_currentuserinfo
    - called 1 time from from auth_redirect
  - called 262 times from get_userdata
    - called 2 times from get_avatar
    - called 20 times from setup_postdata (from
 WP_Post_List_Table::single_row)
    - called 240 times from map_meta_cap
 }}}

 Here's some of the places I could find that call `map_meta_cap` that are
 in a loop for showing posts:

 {{{
  - get_edit_post_link( $post->ID );
  - current_user_can( $post_type_object->cap->edit_post, $post->ID );
  - current_user_can( 'read_post', $post->ID )
  - get_edit_post_link( $post->ID, true )
  - current_user_can( $post_type_object->cap->delete_post, $post->ID )
  - get_delete_post_link( $post->ID )
 ... then in WP_Posts_List_Table::get_inline_data() ...
  - current_user_can($post_type_object->cap->edit_post, $post->ID)
 }}}

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


More information about the wp-trac mailing list