concrete5/concrete5-5.7.0 — pull request #239 by jkoudys (2014-06-10 00:18:31+00:00)
Title: Include msgMailboxID in the key for UserPrivateMessagesTo

Sending a message to yourself will fail, due to UserPrivateMessagesTo declaring a key on msgID, uID (the recipient's uid), and uAuthorID. When your are your own recipient, it attempts to add an entry to both your inbox and your sent mail box, but since the uid and uAuthorID are the same, it violates a unique key restraint and fails badly.

While not the most common scenario, there's still good reason for this to work, especially on any site that heavily uses the messaging system and sends email notifications for every email received (people may email themselves via the site, e.g. if the email-send link contains extra information). I propose fixing this by simply including the mailbox ID in the key too.