diff options
author | Nils Adermann <naderman@naderman.de> | 2012-11-10 13:32:44 +0100 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 16:42:46 -0600 |
commit | b52a0f50ab980ca941267ddb4f509f104b07db77 (patch) | |
tree | d2cefda9978fd976cc69861a38706bc612f2bcda | |
parent | 167faed1630d01e3d592a6696f58316c1d832ff9 (diff) | |
download | forums-b52a0f50ab980ca941267ddb4f509f104b07db77.tar forums-b52a0f50ab980ca941267ddb4f509f104b07db77.tar.gz forums-b52a0f50ab980ca941267ddb4f509f104b07db77.tar.bz2 forums-b52a0f50ab980ca941267ddb4f509f104b07db77.tar.xz forums-b52a0f50ab980ca941267ddb4f509f104b07db77.zip |
[feature/migrations] Update 3.0.3-3.0.5 migrations to work
-rw-r--r-- | phpBB/includes/db/migration/305rc1part2.php | 34 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v303rc1.php | 100 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v304.php | 15 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v304rc1.php | 13 | ||||
-rw-r--r-- | phpBB/includes/db/migration/v305rc1.php | 105 |
5 files changed, 107 insertions, 160 deletions
diff --git a/phpBB/includes/db/migration/305rc1part2.php b/phpBB/includes/db/migration/305rc1part2.php new file mode 100644 index 0000000000..238e533b06 --- /dev/null +++ b/phpBB/includes/db/migration/305rc1part2.php @@ -0,0 +1,34 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v305rc1part2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v305rc1'); + } + + function update_schema() + { + return array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v303rc1.php b/phpBB/includes/db/migration/v303rc1.php index b8ec5668fd..7518a6ed54 100644 --- a/phpBB/includes/db/migration/v303rc1.php +++ b/phpBB/includes/db/migration/v303rc1.php @@ -35,93 +35,20 @@ class phpbb_db_migration_v303rc1 extends phpbb_db_migration array('config.add', array('enable_queue_trigger', '0')), array('config.add', array('queue_trigger_posts', '3')), array('config.add', array('pm_max_recipients', '0')), - array('custom', array('set_group_default_max_recipients')) - - // Not prefilling yet - set_config('dbms_version', ''); - - // Add new permission u_masspm_group and duplicate settings from u_masspm - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_masspm_group'])) - { - $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_masspm']; - $new_id = $auth_admin->acl_options['id']['u_masspm_group']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - /** - * Do not resync post counts here. An admin may do this later from the ACP - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; - _sql($sql, $errored, $error_ary); - - do - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 - GROUP BY poster_id'; - $result = _sql($sql, $errored, $error_ary); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - _sql($sql, $errored, $error_ary); - } - while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - */ + array('custom', array(array(&$this, 'set_group_default_max_recipients'))), + array('config.add', array('dbms_version', '')), + array('permission.add', array('u_masspm_group', phpbb_auth::IS_GLOBAL), + array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + )); + } - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - _sql($sql, $errored, $error_ary); + function correct_acp_email_permissions() + { + $sql = 'UPDATE ' . $this->table_prefix . 'modules + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + $this->sql_query($sql); } function set_group_default_max_recipients() @@ -131,5 +58,4 @@ class phpbb_db_migration_v303rc1 extends phpbb_db_migration WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); $this->sql_query($sql); } - } diff --git a/phpBB/includes/db/migration/v304.php b/phpBB/includes/db/migration/v304.php index 2895caaa6d..5358bcc20f 100644 --- a/phpBB/includes/db/migration/v304.php +++ b/phpBB/includes/db/migration/v304.php @@ -21,20 +21,27 @@ class phpbb_db_migration_v304 extends phpbb_db_migration function update_data() { + return array( + array('custom', array(array(&$this, 'rename_log_delete_topic'))), + ); + } + + function rename_log_delete_topic() + { if ($db->sql_layer == 'oracle') { // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . LOG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "log SET log_operation = 'LOG_DELETE_TOPIC' WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } else { - $sql = 'UPDATE ' . LOG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "log SET log_operation = 'LOG_DELETE_TOPIC' WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } } } diff --git a/phpBB/includes/db/migration/v304rc1.php b/phpBB/includes/db/migration/v304rc1.php index a7098ce62f..2daad4e826 100644 --- a/phpBB/includes/db/migration/v304rc1.php +++ b/phpBB/includes/db/migration/v304rc1.php @@ -57,12 +57,19 @@ class phpbb_db_migration_v304rc1 extends phpbb_db_migration function update_data() { + return array( + array('custom', array(array(&$this, 'update_custom_profile_fields'))), + ); + } + + function update_custom_profile_fields() + { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide FROM ' . PROFILE_FIELDS_TABLE; - $result = _sql($sql, $errored, $error_ary); + $result = $this->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $sql_ary = array( 'field_required' => 0, @@ -90,7 +97,7 @@ class phpbb_db_migration_v304rc1 extends phpbb_db_migration $sql_ary['field_show_profile'] = 1; } - _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); } } } diff --git a/phpBB/includes/db/migration/v305rc1.php b/phpBB/includes/db/migration/v305rc1.php index 8d9c4d2456..4f20796608 100644 --- a/phpBB/includes/db/migration/v305rc1.php +++ b/phpBB/includes/db/migration/v305rc1.php @@ -27,28 +27,29 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration function update_data() { - // Captcha config variables - set_config('captcha_gd_wave', 0); - set_config('captcha_gd_3d_noise', 1); - set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); + $search_indexing_state = $this->config['search_indexing_state']; - // Maximum number of keywords - set_config('max_num_search_keywords', 10); - - // Remove static config var and put it back as dynamic variable - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET is_dynamic = 1 - WHERE config_name = 'search_indexing_state'"; - _sql($sql, $errored, $error_ary); + return array( + array('config.add', array('captcha_gd_wave', 0)), + array('config.add', array('captcha_gd_3d_noise', 1)), + array('config.add', array('captcha_gd_refresh', 1)), + array('config.add', array('confirm_refresh', 1)), + array('config.add', array('max_num_search_keywords', 10)), + array('config.remove', array('search_indexing_state')), + array('config.add', array('search_indexing_state', $search_indexing_state, true)), + array('custom', array(array(&$this, 'hash_old_passwords'))), + array('custom', array(array(&$this, 'update_ichiro_bot'))), + ); + } - // Hash old MD5 passwords + function hash_old_passwords() + { $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' + FROM ' . $this->table_prefix . 'users WHERE user_pass_convert = 1'; - $result = _sql($sql, $errored, $error_ary); + $result = $this->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { if (strlen($row['user_password']) == 32) { @@ -56,33 +57,36 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration 'user_password' => phpbb_hash($row['user_password']), ); - _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); + $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); } } $db->sql_freeresult($result); + } + function update_ichiro_bot() + { // Adjust bot entry - $sql = 'UPDATE ' . BOTS_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "bots SET bot_agent = 'ichiro/' WHERE bot_agent = 'ichiro/2'"; - _sql($sql, $errored, $error_ary); - + $this->sql_query($sql); + } + function remove_duplicate_auth_options() + { // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - - // We get duplicate entries first $sql = 'SELECT auth_option - FROM ' . ACL_OPTIONS_TABLE . ' + FROM ' . $this->table_prefix . 'acl_options GROUP BY auth_option HAVING COUNT(*) >= 2'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $auth_options = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $auth_options[] = $row['auth_option']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); // Remove specific auth options if (!empty($auth_options)) @@ -95,52 +99,21 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration WHERE auth_option = '" . $db->sql_escape($option) . "' ORDER BY auth_option_id DESC"; // sql_query_limit not possible here, due to bug in postgresql layer - $result = $db->sql_query($sql); + $result = $this->sql_query($sql); // Skip first row, this is our original auth option we want to preserve - $row = $db->sql_fetchrow($result); + $row = $this->db->sql_fetchrow($result); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { // Ok, remove this auth option... - _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } } - - // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. - $changes = array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - ); - - global $db_tools; - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $changes = array( - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } } } |