diff options
author | Nathaniel Guse <nathaniel.guse@gmail.com> | 2012-11-09 10:54:33 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 16:42:43 -0600 |
commit | b999a75528156b2cf229cc2ceac04b5a8bac859d (patch) | |
tree | 33905bff1f2a0655364eef57d83360f9361111f3 | |
parent | b1f9ca2f6541924c75a30c68dd8a4bc8db62205d (diff) | |
download | forums-b999a75528156b2cf229cc2ceac04b5a8bac859d.tar forums-b999a75528156b2cf229cc2ceac04b5a8bac859d.tar.gz forums-b999a75528156b2cf229cc2ceac04b5a8bac859d.tar.bz2 forums-b999a75528156b2cf229cc2ceac04b5a8bac859d.tar.xz forums-b999a75528156b2cf229cc2ceac04b5a8bac859d.zip |
[feature/migrations] Some migrations data
PHPBB3-9737
-rw-r--r-- | phpBB/includes/db/migration/v3010rc1.php | 7 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v3011rc1.php | 57 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v309rc1.php | 42 |
3 files changed, 63 insertions, 43 deletions
diff --git a/phpBB/includes/db/migration/v3010rc1.php b/phpBB/includes/db/migration/v3010rc1.php index 9a43b4c81d..847fe7c250 100644 --- a/phpBB/includes/db/migration/v3010rc1.php +++ b/phpBB/includes/db/migration/v3010rc1.php @@ -21,9 +21,8 @@ class phpbb_db_migration_v3010rc1 extends phpbb_db_migration function update_data() { - if (!isset($config['email_max_chunk_size'])) - { - set_config('email_max_chunk_size', '50'); - } + return array( + array('config.add', array('email_max_chunk_size', 50)), + ); } } diff --git a/phpBB/includes/db/migration/v3011rc1.php b/phpBB/includes/db/migration/v3011rc1.php index 04f86b47ae..aad80ba59f 100644 --- a/phpBB/includes/db/migration/v3011rc1.php +++ b/phpBB/includes/db/migration/v3011rc1.php @@ -21,27 +21,38 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration function update_data() { + return array( + array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), + array('custom', array(array(&$this, 'delete_orphan_private_messages'))), + ); + } + + function cleanup_deactivated_styles() + { // Updates users having current style a deactivated one $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' WHERE style_active = 0'; - $result = $db->sql_query($sql); + $result = $this->sql_query($sql); $deactivated_style_ids = array(); - while ($style_id = $db->sql_fetchfield('style_id', false, $result)) + while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) { $deactivated_style_ids[] = (int) $style_id; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (!empty($deactivated_style_ids)) { $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $config['default_style'] .' - WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); - _sql($sql, $errored, $error_ary); + SET user_style = ' . (int) $this->config['default_style'] .' + WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); + $this->sql_query($sql, $errored, $error_ary); } + } + function delete_orphan_private_messages() + { // Delete orphan private messages $batch_size = 500; @@ -58,26 +69,28 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration ), 'WHERE' => 't.user_id IS NULL', ); - $sql = $db->sql_build_query('SELECT', $sql_array); + $sql = $this->db->sql_build_query('SELECT', $sql_array); - do + $result = $this->db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $this->db->sql_fetchrow($result)) { - $result = $db->sql_query_limit($sql, $batch_size); + $delete_pms[] = (int) $row['msg_id']; + } + $db->sql_freeresult($result); - $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 ' . $this->db->sql_in_set('msg_id', $delete_pms); + $this->sql_query($sql, $errored, $error_ary); - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_pms); - _sql($sql, $errored, $error_ary); - } + return true; + } + else + { + return false; } - while (sizeof($delete_pms) == $batch_size); } } diff --git a/phpBB/includes/db/migration/v309rc1.php b/phpBB/includes/db/migration/v309rc1.php index ca56a4e7d9..ce51e54642 100644 --- a/phpBB/includes/db/migration/v309rc1.php +++ b/phpBB/includes/db/migration/v309rc1.php @@ -53,46 +53,54 @@ class phpbb_db_migration_v309rc1 extends phpbb_db_migration function update_data() { - set_config('ip_login_limit_max', '50'); - set_config('ip_login_limit_time', '21600'); - set_config('ip_login_limit_use_forwarded', '0'); + return array( + array('config.add', array('ip_login_limit_max', 50)), + array('config.add', array('ip_login_limit_time', 21600)), + array('config.add', array('ip_login_limit_use_forwarded', 0)), + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), + ); + } + function update_file_extension_group_names() + { // Update file extension group names to use language strings, again. $sql = 'SELECT group_id, group_name FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); - $result = $db->sql_query($sql); + WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $sql_ary = array( 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' ); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE group_id = ' . $row['group_id']; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql, $errored, $error_ary); } - $db->sql_freeresult($result); - - global $db_tools, $table_prefix; + $this->db->sql_freeresult($result); + } + function fix_firebird_qa_captcha() + { // Recover from potentially broken Q&A CAPTCHA table on firebird // Q&A CAPTCHA was uninstallable, so it's safe to remove these // without data loss - if ($db_tools->sql_layer == 'firebird') + if ($this->db_tools->sql_layer == 'firebird') { $tables = array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', + $this->table_prefix . 'captcha_questions', + $this->table_prefix . 'captcha_answers', + $this->table_prefix . 'qa_confirm', ); foreach ($tables as $table) { - if ($db_tools->sql_table_exists($table)) + if ($this->db_tools->sql_table_exists($table)) { - $db_tools->sql_table_drop($table); + $this->db_tools->sql_table_drop($table); } } } |