[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 17:58:00 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                          |  Resolution:
 Keywords:  dev-feedback reporter-feedback  |
--------------------------------------------+------------------------------

Comment (by wpdennis):

 Oh no, I don't think it's pressing to reduce the amount of instance of
 BP_Messages_Thread. But while I was digging why there are so many queries,
 I saw that BP_Messages_Thread is created twice per conversation, which
 looked odd to me and I thought it's worth a look from you guys.

 But if it stays like this, could populate() being cached? This line is
 executed twice per conversation:

 {{{
 if ( !$this->messages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM
 {$bp->messages->table_name_messages} WHERE thread_id = %d ORDER BY
 date_sent " . $order, $this->thread_id ) ) ) {
         return false;
 }
 }}}

 Resulting in 20 queries per page load for a standard inbox with 10
 conversations. I'm not sure how often the data will change. At least I
 have no option in the UI to modify the sort order, so maybe just when
 messages are added or deleted?

 If so, it could be cached permanently till invalidation. If not, maybe it
 could be cached at least non persistant? So it would only query the
 dabatase once per conversation?

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


More information about the buddypress-trac mailing list