[buddypress-trac] [BuddyPress Trac] #8750: Unread count not set for message threads

buddypress-trac noreply at wordpress.org
Mon Oct 10 19:37:00 UTC 2022


#8750: Unread count not set for message threads
--------------------------------------+---------------------
 Reporter:  sjregan                   |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  10.5.0
Component:  Messages                  |     Version:  10.4.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |
--------------------------------------+---------------------

Comment (by imath):

 Ok I got it, if you look at
 https://github.com/buddypress/buddypress/blob/e0f5aaa4746fbbd9bee36fa810eaf67e103f1013/src
 /bp-messages/classes/class-bp-messages-thread.php#L53 You'll see that the
 `unread_count` is designed to inform about the logged in user's unread
 count. It's set there
 https://github.com/buddypress/buddypress/blob/e0f5aaa4746fbbd9bee36fa810eaf67e103f1013/src
 /bp-messages/classes/class-bp-messages-thread.php#L163|L172

 So I believe we should only try to set the unread_count into the
 `BP_Messages_Thread->get_recipients()` method if the `user_id` argument is
 sent to it (via `$args` param) which means it comes from the
 `BP_Messages_Thread->populate()` method.

 While you're right about the fact preserving keys when using
 `array_slice()` was needed when this unread count was being set into
 `BP_Messages_Thread->populate()` (which means it's a regression we
 introduced in 10.0), I believe it might not be needed anymore 😅.

 I've added a unit test to show the issue.

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


More information about the buddypress-trac mailing list