[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
 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
 /bp-messages-classes.php#L116 BP_Messages_Thread::populate()] twice per

 => BP_Messages_Box_Template->__construct()
 => BP_Messages_Thread::get_current_threads_for_user()
 => BP_Messages_Thread->__construct()


 => 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

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

More information about the buddypress-trac mailing list