Skip to:
Content

Opened 4 years ago

Closed 4 years ago

#6580 closed defect (bug) (fixed)

BP_Messages_Thread::$last_message_* not populated by default

Reported by: jdgrimes Owned by: boonebgorges
Milestone: 2.4 Priority: normal
Severity: normal Version: 1.6
Component: Messages Keywords: has-patch
Cc:

Description

The BP_Messages_Thread class offers some convenience fields that grant direct access to the data for the last message in the thread:

  • last_message_id
  • last_message_date
  • last_sender_id
  • last_message_subject
  • last_message_content

However, these are only populated by BP_Messages_Thread_Template::__construct(), and were not documented in BP_Message_Thread until [5999].

This caused me confusion when I was trying to use these fields in a different context. To keep others from spending time chasing this down, I suggest that we do one of the following:

  1. Add a note to the inline docs for each of these fields stating that they are only populated when using BP_Messages_Thread_Template.
  2. Always populate them inside of the BP_Message_Thread::populate() method.

I favor the latter.

Attachments (3)

6580.diff (3.1 KB) - added by jdgrimes 4 years ago.
Always populate the fields
6580.2.diff (3.4 KB) - added by jdgrimes 4 years ago.
Improved unit test
doc-fixes.diff (676 bytes) - added by jdgrimes 4 years ago.
Fixes docblocks of $messages and $recipients fields object -> object[]

Download all attachments as: .zip

Change History (6)

@jdgrimes
4 years ago

Always populate the fields

#1 @jdgrimes
4 years ago

  • Keywords has-patch added

I've uploaded 6580.diff, which always populates the fields. It includes a basic unit test.

@jdgrimes
4 years ago

Improved unit test

@jdgrimes
4 years ago

Fixes docblocks of $messages and $recipients fields object -> object[]

#2 @boonebgorges
4 years ago

  • Component changed from Component - Members to Component - Messaging
  • Milestone changed from Awaiting Review to 2.4

Definitely - I don't see any reason not to do this.

Thanks for the patch, jdgrimes.

#3 @boonebgorges
4 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 10038:

BP_Messages_Thread objects should always have last_message_* properties set.

Previously, they were only set in the context of a template loop.

Props jdgrimes.
Fixes #6580.

Note: See TracTickets for help on using tickets.