diff options
author | Victor A. Safronov <vitek@vitek.tomsk.ru> | 2016-11-30 23:59:36 +0400 |
---|---|---|
committer | Victor A. Safronov <vitek@vitek.tomsk.ru> | 2016-11-30 23:59:36 +0400 |
commit | 10753454bf697f411051988e7c841d1eb80cd114 (patch) | |
tree | 32d9b9a968626b4cbb10563861f87fe78e9fb9da /phpBB | |
parent | a3faf1fefc884c55d870b5fbd0d7b19371907e6c (diff) | |
download | forums-10753454bf697f411051988e7c841d1eb80cd114.tar forums-10753454bf697f411051988e7c841d1eb80cd114.tar.gz forums-10753454bf697f411051988e7c841d1eb80cd114.tar.bz2 forums-10753454bf697f411051988e7c841d1eb80cd114.tar.xz forums-10753454bf697f411051988e7c841d1eb80cd114.zip |
[ticket/13757] Prevents the count of unread PMs from being negative
Sometimes the user_unread_privmsg flag in users table can become negative.
It happens when the unread message is requested by simultaneous concurrent
requests. Both requests will decrement the value of the flag.
This commit prevents updating the flag if the message already marked as read.
PHPBB3-13757
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 6 |
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"; |