1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-20 23:51:28 +01:00

[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
This commit is contained in:
Victor A. Safronov 2016-11-30 23:59:36 +04:00
parent a3faf1fefc
commit 10753454bf

View File

@ -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";