Wrong count of new messages at menu ("Inbox (xxx)") even though there's no unread messages in the Inbox
vito_a - November 6, 2009 - 20:04
| Project: | Privatemsg |
| Version: | 5.x-3.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
At the privatemsg 5.x - 3.0 module it shows some new messages at menu ("Inbox (xxx)") even though there's no unread messages in the Inbox. It does count of messages by the whole privatemsg table at line 2101:
function _privatemsg_get_new_messages($uid = 0) {
...
$cache[$uid] = (int)db_result(db_query('SELECT COUNT(*) FROM {privatemsg} WHERE recipient = %d AND newmsg = 1 AND recipient_del = 0', $uid));
...
}but it looks for unread messages only for users that are exist at line 713:
function privatemsg_list($uid = NULL) {
...
$sql1 = "SELECT id, subject, p.timestamp, u.uid, u.name, newmsg, type FROM {privatemsg} p INNER JOIN {users} u ON ";
...
}( INNER JOIN {users} there ).
But if some users were deleted already, there are some unread messages from deleted users and these messages aren't shown at folders.
Can you fix this please?

#1
Attached a patch here.
I've checked it locally, it just does "INNER JOIN {users} u ON p.author = u.uid" so it's just messages from deleted users woudn't be counted at Inbox (these aren't shown in the module already).
Can someone be so kind to test it against 5.x-3.0 please?
#2
Seems that the previous one was a bit wrong.
Can you please test this against 3.0 not the above one.
It just seems I can't just delete and reattach my previous one attached to the comment. Can someone with corresponding permissions do that?
#3
if I remember correctly, 5.x-3.x would also count new messages that were deleted before being read in its unread count... is that still the case?
EDIT - looking at the patch, that has been fixed previously, or I was misremembering.