[buddypress-trac] [BuddyPress Trac] #6221: messages-loop.php executes BP_Messages_Thread::populate() twice per conversation

buddypress-trac noreply at wordpress.org
Fri Feb 13 09:31:02 UTC 2015


#6221: messages-loop.php executes BP_Messages_Thread::populate() twice per
conversation
-----------------------------------+-----------------------------
 Reporter:  wpdennis               |      Owner:
     Type:  enhancement            |     Status:  new
 Priority:  normal                 |  Milestone:  Awaiting Review
Component:  Component - Messaging  |    Version:
 Severity:  normal                 |   Keywords:  dev-feedback
-----------------------------------+-----------------------------
 messages-loop.php calls
 [https://buddypress.trac.wordpress.org/browser/tags/2.2.0/src/bp-messages
 /bp-messages-classes.php#L116 BP_Messages_Thread::populate()] twice per
 conversation:

 {{{
 bp_has_message_threads()
 => BP_Messages_Box_Template->__construct()
 => BP_Messages_Thread::get_current_threads_for_user()
 => BP_Messages_Thread->__construct()
 }}}

 and

 {{{
 bp_message_thread_total_and_unread_count()
 => bp_get_message_thread_total_count(),
 => BP_Messages_Thread_Template->__construct(),
 => BP_Messages_Thread->__construct()
 }}}


 For 10 conversations this produces 20 db queries.

 '''Related:''' I opened a ticket with the exact same problem for
 BP_Messages_Thread::get_recipients() #6220.

 In ''get_recipients()'' caching would definitly be a good way, even if it
 is called just once per conversation.

 On populate() I'm not so sure if object caching is the right answer. But
 if it's not, it shouldn't be called twice.

 On the other hand... Even with caching, it's maybe worth a look if it can
 be avoided to create the ''BP_Messages_Thread'' object twice per
 conversation.

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


More information about the buddypress-trac mailing list