mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-20 15:53:14 +02:00
[ticket/10950] Update undelivered pm counts in batches not 1 by 1 for each user
PHPBB3-10950
This commit is contained in:
parent
d883535b10
commit
d9a32ce614
@ -1175,16 +1175,29 @@ function phpbb_delete_user_pms($user_id)
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$undelivered_user[$row['user_id']] = (int) $row['num_undelivered_privmsgs'];
|
||||
$num_pms = (int) $row['num_undelivered_privmsgs'];
|
||||
$undelivered_user[$num_pms][] = (int) $row['user_id'];
|
||||
|
||||
if (sizeof($undelivered_user[$num_pms]) > 50)
|
||||
{
|
||||
// If there are too many users affected the query might get
|
||||
// too long, so we update the value for the first bunch here.
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
|
||||
user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
|
||||
WHERE ' . $db->sql_in_set('user_id', $undelivered_user[$num_pms]);
|
||||
$db->sql_query($sql);
|
||||
unset($undelivered_user[$num_pms]);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($undelivered_user as $undelivered_user_id => $count)
|
||||
foreach ($undelivered_user as $num_pms => $undelivered_user_set)
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_new_privmsg = user_new_privmsg - ' . $count . ',
|
||||
user_unread_privmsg = user_unread_privmsg - ' . $count . '
|
||||
WHERE user_id = ' . $undelivered_user_id;
|
||||
SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
|
||||
user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
|
||||
WHERE ' . $db->sql_in_set('user_id', $undelivered_user_set);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user