aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-12-01 11:41:17 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-12-01 11:41:17 +0100
commit365489a3171b4d16e645215c4fe4e39ae7c95f4c (patch)
tree32d9b9a968626b4cbb10563861f87fe78e9fb9da
parenta3faf1fefc884c55d870b5fbd0d7b19371907e6c (diff)
parent10753454bf697f411051988e7c841d1eb80cd114 (diff)
downloadforums-365489a3171b4d16e645215c4fe4e39ae7c95f4c.tar
forums-365489a3171b4d16e645215c4fe4e39ae7c95f4c.tar.gz
forums-365489a3171b4d16e645215c4fe4e39ae7c95f4c.tar.bz2
forums-365489a3171b4d16e645215c4fe4e39ae7c95f4c.tar.xz
forums-365489a3171b4d16e645215c4fe4e39ae7c95f4c.zip
Merge pull request #4548 from nicebb/ticket/13757
[ticket/13757] Prevents the count of unread PMs from being negative
-rw-r--r--phpBB/includes/functions_privmsgs.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 1639eb1a4c..d7a87ca356 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -892,6 +892,12 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
AND folder_id = $folder_id";
$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";