mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 20:38:52 +00:00
[ticket/10605] Delete orphan private messages on update
PHPBB3-10605
This commit is contained in:
parent
17f5c6bf71
commit
45f39c6d1f
1 changed files with 42 additions and 0 deletions
|
@ -2024,6 +2024,48 @@ function change_database_data(&$no_updates, $version)
|
|||
// No changes from 3.0.10-RC3 to 3.0.10
|
||||
case '3.0.10-RC3':
|
||||
break;
|
||||
|
||||
// Changes from 3.0.10 to 3.0.11-RC1
|
||||
case '3.0.10':
|
||||
// Delete orphan private messages
|
||||
$batch_size = 500;
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.msg_id',
|
||||
'FROM' => array(
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(PRIVMSGS_TO_TABLE, 't'),
|
||||
'ON' => 'p.msg_id = t.msg_id',
|
||||
),
|
||||
),
|
||||
'WHERE' => 't.user_id IS NULL';
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
|
||||
do
|
||||
{
|
||||
$result = $db->sql_query_limit($sql, $batch_size);
|
||||
|
||||
$delete_pms = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$delete_pms[] = (int) $row['msg_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!empty($delete_pms))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('msg_id', $delete_pms);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
while (sizeof($delete_pms) == $batch_size);
|
||||
|
||||
$no_updates = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue