[buddypress-trac] [BuddyPress Trac] #5815: bp_blogs_total_blogs_for_user() queries database on each page view in multisite

buddypress-trac noreply at wordpress.org
Thu Aug 14 21:00:55 UTC 2014


#5815: bp_blogs_total_blogs_for_user() queries database on each page view in
multisite
--------------------------+-----------------------------
 Reporter:  wpdennis      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Blogs         |    Version:
 Severity:  normal        |   Keywords:  dev-feedback
--------------------------+-----------------------------
 ''bp_blogs_total_blogs_for_user()'' gets triggered by
 ''BP_Blogs_Component->setup_nav()'' in multisite environments.

 If the visitor isn't logged in, this is resulting in a database query on
 each page view. The caching fails, since the result for logged out users
 is always 0:

 {{{
 if ( !$count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' )
 ) {
 }}}

 ----

 Maybe ''bp_blogs_total_blogs_for_user()'' could return 0 if the current
 user isn't logged in:

 {{{
 if (!is_user_logged_in())
     return 0;
 }}}

 And/or the caching condition should be:

 {{{
 if ( false === $count = wp_cache_get( 'bp_total_blogs_for_user_' .
 $user_id, 'bp' ) ) {
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5815>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list