diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-05-14 00:38:54 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-05-14 00:38:54 +0200 |
commit | 86fa185a1ba4754b6c2dc9769b826aa9d57aa148 (patch) | |
tree | 0a0376f7a54d0cdce0d64ef970a393a40ccc613e /phpBB/install/database_update.php | |
parent | 92d17cbff3800488deb52bd2088f418f2da44458 (diff) | |
parent | 95e1d4e9db8d2174c8ee5c6bb35be06abc57e3cf (diff) | |
download | forums-86fa185a1ba4754b6c2dc9769b826aa9d57aa148.tar forums-86fa185a1ba4754b6c2dc9769b826aa9d57aa148.tar.gz forums-86fa185a1ba4754b6c2dc9769b826aa9d57aa148.tar.bz2 forums-86fa185a1ba4754b6c2dc9769b826aa9d57aa148.tar.xz forums-86fa185a1ba4754b6c2dc9769b826aa9d57aa148.zip |
Merge branch 'ticket/10605' into develop-olympus
* ticket/10605:
[ticket/10605] Use database updater function _sql() instead of $db->sql_query()
[ticket/10605] Put end of array on its own line because start of array is too.
[ticket/10605] Add parameter documentation to phpbb_delete_user_pms
[ticket/10605] Fix left join usage.
[ticket/10605] Add a section for updating from 3.0.10 to schema updates.
[ticket/10605] Fix syntax error in database updater.
[ticket/10605] Reset userĀ“s pm count to 0 when deleting his PMs
[ticket/10605] Split query to be able to use indexes
[ticket/10605] Rename $delete_rows to $delete_ids.
[ticket/10605] Break long comment into multiple lines 80 chars short.
[ticket/10605] Remove unnecessary $delete_ids array.
[ticket/10605] Remove unnecessary array_keys calls on $delete_rows.
[ticket/10605] Remove unused variable declarations.
[ticket/10605] Turn $undelivered_user into a real array of counters.
[ticket/10605] Use unset() instead of checking user_id over and over again.
[ticket/10605] Prefix function with phpbb_ and use true instead of 1
[ticket/10605] Delete orphan private messages on update
[ticket/10605] Check for orphan privmsgs when deleting a user
Conflicts:
phpBB/install/database_update.php
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r-- | phpBB/install/database_update.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6097341ace..c700b483a5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2026,7 +2026,7 @@ 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': // Updates users having current style a deactivated one @@ -2050,6 +2050,44 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } + // 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); + _sql($sql, $errored, $error_ary); + } + } + while (sizeof($delete_pms) == $batch_size); + $no_updates = false; break; } |