Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix messages being sent to wrong or nonexistent users when sending to a user group #13796
Fixes bug with Message Create processor using the wrong recipient ID when processing usergroup messages.
What does it do?
Modified the method to get the 'member' field of the modUserGroupMember object rather than the 'id' field.
Why is it needed?
Messages to user groups are sent to wrong or non-existent users.
Sure, it's confusing because of the variable names. Both $users and $primaryKey are misleading names.
The purpose of the function is to assemble an array of user IDs to send a message to.
When sending to a usergroup, the $users variable holds, not users, but modUserGroupMember objects. In that case $primaryKey is set to 'member', which is the field that holds the member's user ID.
Hardcoding 'id' in that line adds the ID of the modUserGroupMember object (not the user) to the $recipients array, so the message is stored in the DB, but the intended recipient can't see it because it has the wrong User ID.
BTW, a sanity check to make sure the recipient exists would be a good idea too. Otherwise, over time you could amass lots of messages that can't be removed cluttering up the DB.