[buddypress-trac] [BuddyPress] #3167: Can't reply to PM from admin user with older versions of PHP
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Fri Apr 22 18:59:43 UTC 2011
#3167: Can't reply to PM from admin user with older versions of PHP
-----------------------+-----------------------------
Reporter: rebootnow | Owner: johnjamesjacoby
Type: defect | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Messaging | Version: 1.2.8
Keywords: |
-----------------------+-----------------------------
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.
--
Ticket URL: <https://trac.buddypress.org/ticket/3167>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list