aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-02-18 12:16:21 +0100
committerJoas Schilling <nickvergessen@gmx.de>2012-02-27 16:05:12 +0100
commit45f39c6d1f2adc318d521bd9eb75d80f0750fdb8 (patch)
treecaf67b16ae9393b44a7a96ec91514f8fb7e335be /phpBB/install
parent17f5c6bf71f560be2f4e2ecabae83ab2973bec47 (diff)
downloadforums-45f39c6d1f2adc318d521bd9eb75d80f0750fdb8.tar
forums-45f39c6d1f2adc318d521bd9eb75d80f0750fdb8.tar.gz
forums-45f39c6d1f2adc318d521bd9eb75d80f0750fdb8.tar.bz2
forums-45f39c6d1f2adc318d521bd9eb75d80f0750fdb8.tar.xz
forums-45f39c6d1f2adc318d521bd9eb75d80f0750fdb8.zip
[ticket/10605] Delete orphan private messages on update
PHPBB3-10605
Diffstat (limited to 'phpBB/install')
-rw-r--r--phpBB/install/database_update.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index a1b7dcd47f..b6298ca651 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -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;
}
}