Opened 14 years ago
Closed 14 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.
Good catch! Can you work up a patch?