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.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 69c3dad9e6..ff962075a8 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";
@@ -2151,7 +2158,7 @@ function phpbb_get_max_setting_from_group(\phpbb\db\driver\driver_interface $db,
}
// Get maximum number of allowed recipients
- $sql = 'SELECT MIN(g.group_' . $setting . ') as min_setting, MAX(g.group_' . $setting . ') as max_setting
+ $sql = 'SELECT MAX(g.group_' . $setting . ') as max_setting
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
WHERE ug.user_id = ' . (int) $user_id . '
AND ug.user_pending = 0
@@ -2160,9 +2167,8 @@ function phpbb_get_max_setting_from_group(\phpbb\db\driver\driver_interface $db,
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$max_setting = (int) $row['max_setting'];
- $min_setting = (int) $row['min_setting'];
- return ($min_setting > 0) ? $max_setting : 0;
+ return $max_setting;
}
/**