aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_privmsgs.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_privmsgs.php')
-rw-r--r--phpBB/includes/functions_privmsgs.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 1639eb1a4c..4aad1746d5 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -889,9 +889,16 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
SET pm_unread = 0
WHERE msg_id = $msg_id
AND user_id = $user_id
- AND folder_id = $folder_id";
+ AND folder_id = $folder_id
+ AND pm_unread = 1";
$db->sql_query($sql);
+ // If the message is already marked as read, we just skip the rest to avoid negative PM count
+ if (!$db->sql_affectedrows())
+ {
+ return;
+ }
+
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_unread_privmsg = user_unread_privmsg - 1
WHERE user_id = $user_id";