[buddypress-trac] [BuddyPress Trac] #8544: Messages sent at the same time can encounter a race condition where they share the same thread_id

buddypress-trac noreply at wordpress.org
Tue Oct 29 17:06:02 UTC 2024


#8544: Messages sent at the same time can encounter a race condition where they
share the same thread_id
-------------------------------------------------+-------------------------
 Reporter:  petersmithrestless                   |       Owner:
                                                 |  espellcaste
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  low                                  |   Milestone:  Under
                                                 |  Consideration
Component:  Messages                             |     Version:  1.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests needs-    |
  refresh                                        |
-------------------------------------------------+-------------------------
Changes (by espellcaste):

 * milestone:  15.0.0 => Under Consideration


Comment:

 @petersmithrestless I'm curious. When you say two messages are inserted at
 the same time for the thread. Are you talking about two messages from the
 same user? Or two completely separate users (with different thread ids)?

 {{{
 $this->thread_id = (int) $wpdb->get_var( "SELECT MAX(thread_id) FROM {$bp
 ->messages-table_name_messages}" ) + 1;
 }}}

 Currently, the logic has a `+ 1` at the end, and it'd not be possible to
 return the same thread ID. Even if it could, the `+ 1` would increment it.

 But if the `$this->thread_id` is already present, it'd be used. Which I
 guess you are saying this `$this->thread_id` is being set incorrectly to a
 random user. And that's how two separate users' messages can go to the
 same thread?

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


More information about the buddypress-trac mailing list