Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#3167 closed defect (bug) (fixed)

Can't reply to PM from admin user with older versions of PHP

Reported by: rebootnow Owned by: DJPaul
Milestone: 1.5 Priority: normal
Severity: Version: 1.2.8
Component: Messages Keywords:
Cc:

Description

Note: Although this bug is more obvious with older versions of PHP, it probably causes other problems for other versions too.

The bp-messages component does not create an entry for the admin user in the wp_bp_messages_recipients table when admin (user_id = 1) sends PM. As a result, the recipient receives the PM, but the admin doesn't receive future replies.

The bug is in the send method of the BP_Messages_Message class.

around line 300 of bp-messages-classes.php, there is the following test:

if ( !in_array( $this->sender_id, $this->recipients ) )

But here $this->sender_id is a string and $this->recipients is an array of stdClass objects, so the test is broken.

In almost every situation the code works anyway, because most of the time the test fails and the sender gets added as a recipient, and this is normally the right thing to do. But for older versions of PHP (I have repro'd on 5.1.6) the stdClass objects all collapse to "1" and matche the sender ID if that happens to be 1 (admin). So the code thinks that admin is already in the recipient list and doesn't add them to the db table.

I haven't repro'd using the trunk, but from a quick look it seems that this isn't fixed. I also can't find a bug for this issue.

The fix is simple. Just build a list of recipient IDs in the loop immediately preceding the test, and then use that array instead of the array of stdClass objects in the test.

Attachments (1)

bp-messages-classes.php (15.6 KB) - added by rebootnow 10 years ago.
Patched source for 1.2.8

Download all attachments as: .zip

Change History (4)

#1 @cnorris23
10 years ago

Good catch! Can you work up a patch?

@rebootnow
10 years ago

Patched source for 1.2.8

#2 @DJPaul
10 years ago

  • Milestone changed from Awaiting Review to 1.3
  • Owner changed from johnjamesjacoby to DJPaul
  • Status changed from new to assigned

#3 @djpaul
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4242]) Create an array of user IDs for the in_array() check. Fixes #3167, props rebootnow

Note: See TracTickets for help on using tickets.