From 293b65e3efbf94f6521acebe1b9f3e7bbca20286 Mon Sep 17 00:00:00 2001 From: David Tobin Date: Thu, 5 Jul 2012 02:47:49 +0100 Subject: [ticket/10896] Adds email validation to email settings in ACP Adds a new validation type to the ACP validate_config_vars function and implements it on the board_contact and board_email settings. PHPBB3-10896 --- phpBB/includes/acp/acp_board.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index f437dca8f9..ebbf66657e 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -408,8 +408,8 @@ class acp_board 'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true), 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true), - 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), - 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), + 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true), + 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true), 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), -- cgit v1.2.1 From 8d3a82a4fa8ced50fbc1d1019ef439d1d5c81e71 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 19:32:39 -0600 Subject: [feature/migrations] Make the container available to extension installers This allows extensions to load and install migrations easily as per their needs. PHPBB3-11318 --- phpBB/includes/extension/base.php | 15 +++++++++++++++ phpBB/includes/extension/manager.php | 13 ++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index 9d076eb6c5..d51589d719 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\ContainerInterface; + /** * A base class for extensions without custom enable/disable/purge code. * @@ -22,6 +24,19 @@ if (!defined('IN_PHPBB')) */ class phpbb_extension_base implements phpbb_extension_interface { + /** @var ContainerInterface */ + protected $container; + + /** + * Constructor + * + * @param ContainerInterface $container Container object + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } + /** * Single enable step that does nothing * diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index de6f364320..8136dfa90b 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\ContainerInterface; + /** * The extension manager provides means to activate/deactivate extensions. * @@ -22,6 +24,9 @@ if (!defined('IN_PHPBB')) */ class phpbb_extension_manager { + /** @var ContainerInterface */ + protected $container; + protected $db; protected $config; protected $cache; @@ -34,6 +39,7 @@ class phpbb_extension_manager /** * Creates a manager and loads information from database * + * @param ContainerInterface $container A container * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config * @param string $extension_table The name of the table holding extensions @@ -42,8 +48,9 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { + $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; @@ -126,11 +133,11 @@ class phpbb_extension_manager if (class_exists($extension_class_name)) { - return new $extension_class_name; + return new $extension_class_name($this->container); } else { - return new phpbb_extension_base; + return new phpbb_extension_base($this->container); } } -- cgit v1.2.1 From aa67fa6dd83e329c3b6edbb356eae3eeda1ba69f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 31 Jan 2013 13:53:33 -0600 Subject: [feature/migrations] Automatically install/revert migrations for extensions Migrations from ext/ext_name/migrations/ are automatically installed when enabling the extension and automatically reverted when the extension is purged. PHPBB3-11318 --- phpBB/includes/extension/manager.php | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 8136dfa90b..018324d5d6 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -173,6 +173,12 @@ class phpbb_extension_manager $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; + // Returns false if not completed + if (!$this->handle_migrations($name, 'enable')) + { + return true; + } + $extension = $this->get_extension($name); $state = $extension->enable_step($old_state); @@ -324,6 +330,12 @@ class phpbb_extension_manager $old_state = unserialize($this->extensions[$name]['ext_state']); + // Returns false if not completed + if (!$this->handle_migrations($name, 'purge')) + { + return true; + } + $extension = $this->get_extension($name); $state = $extension->purge_step($old_state); @@ -497,4 +509,54 @@ class phpbb_extension_manager { return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); } + + /** + * Handle installing/reverting migrations + * + * @param string $extension_name Name of the extension + * @param string $mode enable or purge + * @return bool True if completed, False if not completed + */ + protected function handle_migrations($extension_name, $mode) + { + $migrator = $this->container->get('migrator'); + $migrations_path = $this->get_extension_path($extension_name) . 'migrations'; + if (file_exists($migrations_path) && is_dir($migrations_path)) + { + $migrator->load_migrations($migrations_path); + } + + // What is a safe limit of execution time? Half the max execution time should be safe. + $safe_time_limit = (ini_get('max_execution_time') / 2); + $start_time = time(); + + if ($mode == 'enable') + { + while (!$migrator->finished()) + { + $migrator->update(); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } + } + } + else if ($mode == 'purge') + { + while ($migrator->migration_state() !== false) + { + $migrator->revert(); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } + } + } + + return true; + } } -- cgit v1.2.1 From fb4f7470d481bd73dd505e7ce0522907f67773ef Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 15:34:03 -0600 Subject: [feature/migrations] Rebuilding migrations data on develop So this is easy to merge later. PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 28 ++ phpBB/includes/db/migration/data/3_0_10.php | 28 ++ phpBB/includes/db/migration/data/3_0_10_rc1.php | 30 ++ phpBB/includes/db/migration/data/3_0_10_rc2.php | 28 ++ phpBB/includes/db/migration/data/3_0_10_rc3.php | 28 ++ phpBB/includes/db/migration/data/3_0_11.php | 28 ++ phpBB/includes/db/migration/data/3_0_11_rc1.php | 94 ++++++ phpBB/includes/db/migration/data/3_0_11_rc2.php | 34 ++ phpBB/includes/db/migration/data/3_0_12_rc1.php | 123 +++++++ phpBB/includes/db/migration/data/3_0_1_rc1.php | 102 ++++++ phpBB/includes/db/migration/data/3_0_2.php | 28 ++ phpBB/includes/db/migration/data/3_0_2_rc1.php | 32 ++ phpBB/includes/db/migration/data/3_0_2_rc2.php | 55 +++ phpBB/includes/db/migration/data/3_0_3.php | 28 ++ phpBB/includes/db/migration/data/3_0_3_rc1.php | 63 ++++ phpBB/includes/db/migration/data/3_0_4.php | 49 +++ phpBB/includes/db/migration/data/3_0_4_rc1.php | 107 ++++++ phpBB/includes/db/migration/data/3_0_5.php | 28 ++ phpBB/includes/db/migration/data/3_0_5_rc1.php | 119 +++++++ .../includes/db/migration/data/3_0_5_rc1part2.php | 37 ++ phpBB/includes/db/migration/data/3_0_6.php | 28 ++ phpBB/includes/db/migration/data/3_0_6_rc1.php | 279 +++++++++++++++ phpBB/includes/db/migration/data/3_0_6_rc2.php | 28 ++ phpBB/includes/db/migration/data/3_0_6_rc3.php | 40 +++ phpBB/includes/db/migration/data/3_0_6_rc4.php | 28 ++ phpBB/includes/db/migration/data/3_0_7.php | 28 ++ phpBB/includes/db/migration/data/3_0_7_pl1.php | 28 ++ phpBB/includes/db/migration/data/3_0_7_rc1.php | 53 +++ phpBB/includes/db/migration/data/3_0_7_rc2.php | 72 ++++ phpBB/includes/db/migration/data/3_0_8.php | 28 ++ phpBB/includes/db/migration/data/3_0_8_rc1.php | 221 ++++++++++++ phpBB/includes/db/migration/data/3_0_9.php | 28 ++ phpBB/includes/db/migration/data/3_0_9_rc1.php | 110 ++++++ phpBB/includes/db/migration/data/3_0_9_rc2.php | 28 ++ phpBB/includes/db/migration/data/3_0_9_rc3.php | 28 ++ phpBB/includes/db/migration/data/3_0_9_rc4.php | 28 ++ phpBB/includes/db/migration/data/3_1_0_dev.php | 375 +++++++++++++++++++++ phpBB/includes/db/migration/data/extensions.php | 55 +++ .../includes/db/migration/data/style_update_p1.php | 157 +++++++++ .../includes/db/migration/data/style_update_p2.php | 42 +++ phpBB/includes/db/migration/data/timezone.php | 161 +++++++++ phpBB/includes/update_helpers.php | 112 ------ 42 files changed, 2914 insertions(+), 112 deletions(-) create mode 100644 phpBB/includes/db/migration/data/3_0_1.php create mode 100644 phpBB/includes/db/migration/data/3_0_10.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_11.php create mode 100644 phpBB/includes/db/migration/data/3_0_11_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_11_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_12_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_1_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_2.php create mode 100644 phpBB/includes/db/migration/data/3_0_2_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_2_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_3.php create mode 100644 phpBB/includes/db/migration/data/3_0_3_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_4.php create mode 100644 phpBB/includes/db/migration/data/3_0_4_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_5.php create mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1part2.php create mode 100644 phpBB/includes/db/migration/data/3_0_6.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc4.php create mode 100644 phpBB/includes/db/migration/data/3_0_7.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_pl1.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_8.php create mode 100644 phpBB/includes/db/migration/data/3_0_8_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_9.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc4.php create mode 100644 phpBB/includes/db/migration/data/3_1_0_dev.php create mode 100644 phpBB/includes/db/migration/data/extensions.php create mode 100644 phpBB/includes/db/migration/data/style_update_p1.php create mode 100644 phpBB/includes/db/migration/data/style_update_p2.php create mode 100644 phpBB/includes/db/migration/data/timezone.php delete mode 100644 phpBB/includes/update_helpers.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php new file mode 100644 index 0000000000..a2332c9b59 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -0,0 +1,28 @@ +sql_query($sql); + + $deactivated_style_ids = array(); + while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) + { + $deactivated_style_ids[] = (int) $style_id; + } + $this->db->sql_freeresult($result); + + if (!empty($deactivated_style_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $this->config['default_style'] .' + WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); + $this->sql_query($sql); + } + } + + function delete_orphan_private_messages() + { + // 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 = $this->db->sql_build_query('SELECT', $sql_array); + + $result = $this->db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $delete_pms[] = (int) $row['msg_id']; + } + $this->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); + + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php new file mode 100644 index 0000000000..f2bed54085 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -0,0 +1,34 @@ + array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.11-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php new file mode 100644 index 0000000000..0d8702f19e --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -0,0 +1,123 @@ +db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); + $this->sql_query($sql); + } + } + + public function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_u_sig\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'signature\''; + $this->sql_query($sql); + } + + public function update_bots() + { + // Update bots + if (!function_exists('user_delete')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $this->db->sql_query($sql); + $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php new file mode 100644 index 0000000000..cf067d2e2c --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -0,0 +1,102 @@ + array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list' => array('BOOL', 1), + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'groups' => array('group_legend'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('session_forum_id'), + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + ); + } + + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list', + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + ), + 'add_index' => array( + $this->table_prefix . 'groups' => array( + 'group_legend' => 'group_legend', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array('session_forum_id'), + $this->table_prefix . 'groups' => array('group_legend_name'), + ), + ); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'fix_unset_last_view_time'))), + array('custom', array(array(&$this, 'reset_smiley_size'))), + + array('config.update', array('version', '3.0.1-rc1')), + ); + } + + function fix_unset_last_view_time() + { + $sql = 'UPDATE ' . $this->table_prefix . "topics + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + $this->sql_query($sql); + } + + function reset_smiley_size() + { + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; + + $this->sql_query($sql); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php new file mode 100644 index 0000000000..3469d8d178 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'drafts' => array( + 'draft_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'posts' => array( + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'topics' => array( + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array('session_forum_id'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid' => array('session_forum_id'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.2-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php new file mode 100644 index 0000000000..dff375f438 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + 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(array(&$this, 'set_group_default_max_recipients'))), + array('config.add', array('dbms_version', $this->db->sql_server_info(true))), + array('permission.add', array('u_masspm_group', true, 'u_masspm')), + array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + + array('config.update', array('version', '3.0.3-rc1')), + ); + } + + 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() + { + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + 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/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php new file mode 100644 index 0000000000..1af4508331 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -0,0 +1,49 @@ +db->sql_layer == 'oracle') + { + // log_operation is CLOB - but we can change this later + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + else + { + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php new file mode 100644 index 0000000000..e9bb0e01f5 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -0,0 +1,107 @@ + array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile' => array('BOOL', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'styles' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_imageset' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_theme' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template_data' => array( + 'template_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'update_custom_profile_fields'))), + + array('config.update', array('version', '3.0.4-rc1')), + ); + } + + 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 = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + $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); + } + + $this->db->sql_freeresult($result); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php new file mode 100644 index 0000000000..2f80970781 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + $search_indexing_state = $this->config['search_indexing_state']; + + 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_fonts', 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'))), + ); + } + + function hash_old_passwords() + { + $sql = 'SELECT user_id, user_password + FROM ' . $this->table_prefix . 'users + WHERE user_pass_convert = 1'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); + } + } + $this->db->sql_freeresult($result); + } + + function update_ichiro_bot() + { + // Adjust bot entry + $sql = 'UPDATE ' . $this->table_prefix . "bots + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + $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 + $sql = 'SELECT auth_option + FROM ' . $this->table_prefix . 'acl_options + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $this->db->sql_query($sql); + + $auth_options = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $this->db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + 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 = $this->db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $this->db->sql_fetchrow($result); + + while ($row = $this->db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + $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']); + } + $this->db->sql_freeresult($result); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php new file mode 100644 index 0000000000..1fab0f8873 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -0,0 +1,37 @@ + array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.5-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php new file mode 100644 index 0000000000..26176b9437 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'confirm' => array( + 'attempts' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported' => array('BOOL', 0), + ), + $this->table_prefix . 'reports' => array( + 'pm_id' => array('UINT', 0), + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + $this->table_prefix . 'reports' => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + $this->table_prefix . 'posts' => array( + 'post_username' => array('post_username:255'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), + array('if', array( + ($this->config['captcha_gd']), + array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), + )), + + array('config.add', array('feed_enable', 0)), + array('config.add', array('feed_limit', 10)), + array('config.add', array('feed_overall_forums', 1)), + array('config.add', array('feed_overall_forums_limit', 15)), + array('config.add', array('feed_overall_topics', 0)), + array('config.add', array('feed_overall_topics_limit', 15)), + array('config.add', array('feed_forum', 1)), + array('config.add', array('feed_topic', 1)), + array('config.add', array('feed_item_statistics', 1)), + + array('config.add', array('smilies_per_page', 50)), + array('config.add', array('allow_pm_report', 1)), + array('config.add', array('min_post_chars', 1)), + array('config.add', array('allow_quick_reply', 1)), + array('config.add', array('new_member_post_limit', 0)), + array('config.add', array('new_member_group_default', 0)), + array('config.add', array('delete_time', $this->config['edit_time'])), + + array('config.add', array('allow_avatar', 0)), + array('if', array( + ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), + array('config.update', array('allow_avatar', 1)), + )), + array('config.add', array('allow_avatar_remote_upload', 0)), + array('if', array( + ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), + array('config.update', array('allow_avatar_remote_upload', 1)), + )), + + array('module.add', array( + 'acp', + 'ACP_BOARD_CONFIGURATION', + array( + 'module_basename' => 'acp_board', + 'modes' => array('feed'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_CAT_USERS', + array( + 'module_basename' => 'acp_users', + 'modes' => array('warnings'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_SERVER_CONFIGURATION', + array( + 'module_basename' => 'acp_send_statistics', + 'modes' => array('send_statistics'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_FORUM_BASED_PERMISSIONS', + array( + 'module_basename' => 'acp_permissions', + 'modes' => array('setting_forum_copy'), + ), + )), + array('module.add', array( + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'mcp_pm_reports', + 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), + ), + )), + array('custom', array(array(&$this, 'add_newly_registered_group'))), + array('custom', array(array(&$this, 'set_user_options_default'))), + + array('config.update', array('version', '3.0.6-rc1')), + ); + } + + function set_user_options_default() + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + $this->sql_query($sql); + } + + function add_newly_registered_group() + { + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $this->db->sql_query($sql); + $group_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + $this->sql_query($sql); + + $group_id = $this->db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $u_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + $this->sql_query($sql); + $u_role = $this->db->sql_nextid(); + + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + $this->sql_query($sql); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + $this->sql_query($sql); + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $f_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + $this->sql_query($sql); + $f_role = $this->db->sql_nextid(); + + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + $this->sql_query($sql); + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + $this->sql_query($sql); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $this->db->sql_query($sql); + $is_options = (int) $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); + } + $this->db->sql_freeresult($result); + } + + // Clear permissions... + include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php new file mode 100644 index 0000000000..4092a5fa61 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -0,0 +1,28 @@ +sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php new file mode 100644 index 0000000000..e748c7a4ff --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'log' => array('log_time'), + ), + 'add_index' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id' => array('topic_id'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('feed_overall', 1)), + array('config.add', array('feed_http_auth', 0)), + array('config.add', array('feed_limit_post', $this->config['feed_limit'])), + array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), + array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), + array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), + array('custom', array(array(&$this, 'delete_text_templates'))), + + array('config.update', array('version', '3.0.7-rc1')), + ); + } + + function delete_text_templates() + { + // Delete all text-templates from the template_data + $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' + WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php new file mode 100644 index 0000000000..4e380c810d --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -0,0 +1,72 @@ + ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $this->db->sql_query_limit($sql, $limit, $start); + + $i = 0; + while ($row = $this->db->sql_fetchrow($result)) + { + $i++; + + // Snapshot of the phpbb_email_hash() function + // We cannot call it directly because the auto updater updates the DB first. :/ + $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); + + if ($user_email_hash != $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + $this->sql_query($sql); + } + } + $this->db->sql_freeresult($result); + + if ($i < $limit) + { + // Completed + return; + } + + return $start + $limit; + } +} diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php new file mode 100644 index 0000000000..a5defc8278 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -0,0 +1,28 @@ + 'acp_board', + 'modes' => array('post'), + ), + )), + array('config.add', array('load_unreads_search', 1)), + array('config.update_if_equals', array(600, 'queue_interval', 60)), + array('config.update_if_equals', array(50, 'email_package_size', 20)), + + array('config.update', array('version', '3.0.8-rc1')), + ); + } + + function update_file_extension_group_names() + { + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; + $this->sql_query($sql); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $this->db->sql_freeresult($result); + } + + function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + $this->sql_query($sql); + } + + function update_bots() + { + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; + $result = $this->db->sql_query($sql); + $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $this->db->sql_query($sql); + $group_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $this->config['default_lang'], + 'user_style' => $this->config['default_style'], + 'user_timezone' => 0, + 'user_dateformat' => $this->config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + $this->sql_query($sql); + } + } + + function delete_orphan_shadow_topics() + { + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); + $this->db->sql_query($sql); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php new file mode 100644 index 0000000000..eb359e2697 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -0,0 +1,28 @@ + array( + $this->table_prefix . 'login_attempts' => array( + 'COLUMNS' => array( + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.12 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + //'PRIMARY_KEY' => 'attempt_id', + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'bbcodes' => array( + 'bbcode_id' => array('USINT', 0), + ), + ), + ); + } + + function update_data() + { + 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'))), + + array('config.update', array('version', '3.0.9-rc1')), + ); + } + + 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 ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); + $result = $this->db->sql_query($sql); + + 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 ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE group_id = ' . $row['group_id']; + $this->sql_query($sql); + } + $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 ($this->db_tools->sql_layer == 'firebird') + { + $tables = array( + $this->table_prefix . 'captcha_questions', + $this->table_prefix . 'captcha_answers', + $this->table_prefix . 'qa_confirm', + ); + foreach ($tables as $table) + { + if ($this->db_tools->sql_table_exists($table)) + { + $this->db_tools->sql_table_drop($table); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php new file mode 100644 index 0000000000..e3c4716665 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -0,0 +1,28 @@ + array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_pm' => array('BOOL', 0), + ), + STYLES_TABLE => array( + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + REPORTS_TABLE => array( + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + + array('config.add', array('fulltext_postgres_ts_name', 'simple')), + array('config.add', array('fulltext_postgres_min_word_len', 4)), + array('config.add', array('fulltext_postgres_max_word_len', 254)), + array('config.add', array('fulltext_sphinx_stopwords', 0)), + array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), + + array('config.add', array('load_jquery_cdn', 0)), + array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), + + array('config.add', array('use_system_cron', 0)), + + array('config.add', array('legend_sort_groupname', 0)), + array('config.add', array('teampage_forums', 1)), + array('config.add', array('teampage_memberships', 1)), + + array('config.add', array('load_cpf_pm', 0)), + + array('config.add', array('display_last_subject', 1)), + + array('config.add', array('assets_version', 1)), + + array('config.add', array('site_home_url', '')), + array('config.add', array('site_home_text', '')), + + array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), + + array('module.add', array( + 'acp', + 'ACP_GROUPS', + array( + 'module_basename' => 'acp_groups', + 'modes' => array('position'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_ATTACHMENTS', + array( + 'module_basename' => 'acp_attachments', + 'modes' => array('manage'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_STYLE_MANAGEMENT', + array( + 'module_basename' => 'acp_styles', + 'modes' => array('install', 'cache'), + ), + )), + array('module.add', array( + 'ucp', + 'UCP_PROFILE', + array( + 'module_basename' => 'ucp_profile', + 'modes' => array('autologin_keys'), + ), + )), + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_LANGUAGE' + )), + + array('module.remove', array( + 'acp', + false, + 'ACP_TEMPLATES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_THEMES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_IMAGESETS', + )), + + array('custom', array(array($this, 'rename_module_basenames'))), + array('custom', array(array($this, 'rename_styles_module'))), + array('custom', array(array($this, 'add_group_teampage'))), + array('custom', array(array($this, 'update_group_legend'))), + array('custom', array(array($this, 'localise_global_announcements'))), + array('custom', array(array($this, 'update_ucp_pm_basename'))), + array('custom', array(array($this, 'update_ucp_profile_auth'))), + array('custom', array(array($this, 'move_customise_modules'))), + + array('config.update', array('version', '3.1.0-dev')), + ); + } + + public function move_customise_modules() + { + // Move language management to new location in the Customise tab + // First get language module id + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_language'"; + $result = $this->db->sql_query($sql); + $language_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $this->db->sql_query($sql); + $language_management_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); + } + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); + } + + public function update_ucp_pm_basename() + { + $sql = 'SELECT module_id, module_basename + FROM ' . MODULES_TABLE . " + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM'"; + $result = $this->db->sql_query_limit($sql, 1); + + if ($row = $this->db->sql_fetchrow($result)) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; + + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + public function update_ucp_profile_auth() + { + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'profile_info'"; + $this->sql_query($sql); + } + + public function rename_styles_module() + { + // Rename styles module to Customise + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + $this->sql_query($sql); + } + + public function rename_module_basenames() + { + // rename all module basenames to full classname + $sql = 'SELECT module_id, module_basename, module_class + FROM ' . MODULES_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $module_id = (int) $row['module_id']; + unset($row['module_id']); + + if (!empty($row['module_basename']) && !empty($row['module_class'])) + { + // all the class names start with class name or with phpbb_ for auto loading + if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && + strpos($row['module_basename'], 'phpbb_') !== 0) + { + $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; + + $sql_update = $this->db->sql_build_array('UPDATE', $row); + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $sql_update . ' + WHERE module_id = ' . $module_id; + $this->sql_query($sql); + } + } + } + + $this->db->sql_freeresult($result); + } + + public function add_group_teampage() + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + $this->sql_query($sql); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + $this->sql_query($sql); + } + + public function update_group_legend() + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $this->db->sql_query($sql); + + $next_legend = 1; + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + $this->sql_query($sql); + + $next_legend++; + } + $this->db->sql_freeresult($result); + } + + public function localise_global_announcements() + { + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $this->db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $this->db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $this->db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST; + $result = $this->db->sql_query_limit($sql, 1); + $ga_forum_id = $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $this->db->sql_query($sql); + $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); + $this->db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + $this->sql_query($sql); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); + $this->sql_query($sql); + } + unset($table_ary); + } + } +} diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php new file mode 100644 index 0000000000..b8379483a3 --- /dev/null +++ b/phpBB/includes/db/migration/data/extensions.php @@ -0,0 +1,55 @@ + array( + EXT_TABLE => array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), + ), + ), + ); + } + + public function update_data() + { + return array( + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_EXTENSION_MANAGEMENT' + )), + array('module.add', array( + 'acp', + 'ACP_EXTENSION_MANAGEMENT', + array( + 'module_basename' => 'acp_extensions', + 'modes' => array('main'), + ), + )), + array('permission.add', array('a_extensions', true, 'a_styles')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php new file mode 100644 index 0000000000..387b37de8e --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -0,0 +1,157 @@ +phpbb_root_path . 'styles'); + $skip_dirs = array('.', '..', 'prosilver'); + foreach ($iterator as $fileinfo) + { + if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) + { + $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); + if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) + { + // 3.1 style + $available_styles[] = $fileinfo->getFilename(); + } + } + } + + // Get all installed styles + if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id + AND i.imageset_id = s.imageset_id"; + } + else + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id"; + } + $result = $this->db->sql_query($sql); + + $styles = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $styles[] = $row; + } + $this->db->sql_freeresult($result); + + // Decide which styles to keep, all others will be deleted + $valid_styles = array(); + foreach ($styles as $style_row) + { + if ( + // Delete styles with parent style (not supported yet) + $style_row['template_inherits_id'] == 0 && + // Check if components match + $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && + // Check if components are valid + in_array($style_row['template_path'], $available_styles) + ) + { + // Valid style. Keep it + $sql_ary = array( + 'style_path' => $style_row['template_path'], + 'bbcode_bitfield' => $style_row['bbcode_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + ); + $this->sql_query('UPDATE ' . STYLES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE style_id = ' . $style_row['style_id']); + $valid_styles[] = (int) $style_row['style_id']; + } + } + + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql_ary = array( + 'style_name' => 'prosilver', + 'style_copyright' => '© phpBB Group', + 'style_active' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'lNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', + + // Will be removed in the next step + 'imageset_id' => 0, + 'template_id' => 0, + 'theme_id' => 0, + ); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->sql_query($sql); + + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = $this->sql_query($sql); + $default_style = $this->db->sql_fetchfield($result); + $this->db->sql_freeresult($result); + + set_config('default_style', $default_style); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $this->sql_query($sql); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' + WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); + + // Change default style + if (!in_array($this->config['default_style'], $valid_styles)) + { + $this->sql_query('UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $valid_styles[0] . "' + WHERE config_name = 'default_style'"); + } + + // Reset styles for users + $this->sql_query('UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); + } + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php new file mode 100644 index 0000000000..db4b7f1753 --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -0,0 +1,42 @@ + array( + STYLES_TABLE => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + + 'drop_tables' => array( + STYLES_IMAGESET_TABLE, + STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_TABLE, + STYLES_TEMPLATE_DATA_TABLE, + STYLES_THEME_TABLE, + ), + ); + } + + public function update_data() + { + return array(); + } +} diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php new file mode 100644 index 0000000000..7734ed4b76 --- /dev/null +++ b/phpBB/includes/db/migration/data/timezone.php @@ -0,0 +1,161 @@ + array( + USERS_TABLE => array( + 'user_timezone' => array('VCHAR:100', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_timezones'))), + ); + } + + public function update_timezones() + { + // Update user timezones + $sql = 'SELECT user_dst, user_timezone + FROM ' . USERS_TABLE . ' + GROUP BY user_timezone, user_dst'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' + AND user_dst = " . (int) $row['user_dst']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + + // Update board default timezone + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' + WHERE config_name = 'board_timezone'"; + $this->sql_query($sql); + + // After we have calculated the timezones we can delete user_dst column from user table. + $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + } + + /** + * Determine the new timezone for a given phpBB 3.0 timezone and + * "Daylight Saving Time" option + * + * @param $timezone float Users timezone in 3.0 + * @param $dst int Users daylight saving time + * @return string Users new php Timezone which is used since 3.1 + */ + public function convert_phpbb30_timezone($timezone, $dst) + { + $offset = $timezone + $dst; + + switch ($timezone) + { + case '-12': + return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time' + case '-11': + return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time' + case '-10': + return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' + case '-9.5': + return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' + case '-9': + return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time' + case '-8': + return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time' + case '-7': + return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time' + case '-6': + return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time' + case '-5': + return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time' + case '-4.5': + return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' + case '-4': + return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time' + case '-3.5': + return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' + case '-3': + return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time' + case '-2': + return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' + case '-1': + return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' + case '0': + return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time' + case '1': + return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time' + case '2': + return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' + case '3': + return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' + case '3.5': + return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' + case '4': + return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' + case '4.5': + return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' + case '5': + return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' + case '5.5': + return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' + case '5.75': + return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' + case '6': + return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' + case '6.5': + return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' + case '7': + return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' + case '8': + return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' + case '8.75': + return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' + case '9': + return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' + case '9.5': + return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' + case '10': + return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' + case '10.5': + return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' + case '11': + return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' + case '11.5': + return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' + case '12': + return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' + case '12.75': + return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' + case '13': + return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' + case '14': + return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' + default: + return 'UTC'; + } + } +} diff --git a/phpBB/includes/update_helpers.php b/phpBB/includes/update_helpers.php deleted file mode 100644 index 69d678b2f8..0000000000 --- a/phpBB/includes/update_helpers.php +++ /dev/null @@ -1,112 +0,0 @@ - Date: Thu, 10 Jan 2013 17:18:12 -0600 Subject: [feature/migrations] Revert schema for migration data PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 5 -- phpBB/includes/db/migration/data/3_0_10.php | 5 -- phpBB/includes/db/migration/data/3_0_10_rc1.php | 5 -- phpBB/includes/db/migration/data/3_0_10_rc2.php | 5 -- phpBB/includes/db/migration/data/3_0_10_rc3.php | 5 -- phpBB/includes/db/migration/data/3_0_11.php | 5 -- phpBB/includes/db/migration/data/3_0_11_rc1.php | 5 -- phpBB/includes/db/migration/data/3_0_11_rc2.php | 11 +++ phpBB/includes/db/migration/data/3_0_12_rc1.php | 5 -- phpBB/includes/db/migration/data/3_0_1_rc1.php | 14 +++- phpBB/includes/db/migration/data/3_0_2.php | 5 -- phpBB/includes/db/migration/data/3_0_2_rc1.php | 5 -- phpBB/includes/db/migration/data/3_0_2_rc2.php | 22 ++++- phpBB/includes/db/migration/data/3_0_3.php | 5 -- phpBB/includes/db/migration/data/3_0_3_rc1.php | 15 ++++ phpBB/includes/db/migration/data/3_0_4.php | 5 -- phpBB/includes/db/migration/data/3_0_4_rc1.php | 11 +++ phpBB/includes/db/migration/data/3_0_5.php | 5 -- .../includes/db/migration/data/3_0_5_rc1part2.php | 4 +- phpBB/includes/db/migration/data/3_0_6.php | 5 -- phpBB/includes/db/migration/data/3_0_6_rc1.php | 40 +++++++++ phpBB/includes/db/migration/data/3_0_6_rc2.php | 5 -- phpBB/includes/db/migration/data/3_0_6_rc3.php | 5 -- phpBB/includes/db/migration/data/3_0_6_rc4.php | 5 -- phpBB/includes/db/migration/data/3_0_7.php | 5 -- phpBB/includes/db/migration/data/3_0_7_pl1.php | 5 -- phpBB/includes/db/migration/data/3_0_7_rc1.php | 20 ++++- phpBB/includes/db/migration/data/3_0_7_rc2.php | 5 -- phpBB/includes/db/migration/data/3_0_8.php | 5 -- phpBB/includes/db/migration/data/3_0_8_rc1.php | 5 -- phpBB/includes/db/migration/data/3_0_9.php | 5 -- phpBB/includes/db/migration/data/3_0_9_rc1.php | 9 ++ phpBB/includes/db/migration/data/3_0_9_rc2.php | 5 -- phpBB/includes/db/migration/data/3_0_9_rc3.php | 5 -- phpBB/includes/db/migration/data/3_0_9_rc4.php | 5 -- phpBB/includes/db/migration/data/3_1_0_dev.php | 37 ++++++-- phpBB/includes/db/migration/data/extensions.php | 11 ++- .../includes/db/migration/data/style_update_p1.php | 11 +-- .../includes/db/migration/data/style_update_p2.php | 98 ++++++++++++++++++++-- phpBB/includes/db/migration/data/timezone.php | 11 +-- phpBB/includes/db/migration/data/timezone_p2.php | 38 +++++++++ 41 files changed, 314 insertions(+), 168 deletions(-) create mode 100644 phpBB/includes/db/migration/data/timezone_p2.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index a2332c9b59..d71288c64b 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_1_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 07410c5ba1..17472562f2 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index daac50a631..eebee44e39 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index 234e4c5fc7..b81fde9bcb 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index 075ce35e3e..d97b0b4aec 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index 0bc9b6c4a5..b149cd374c 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 752efd72b2..3d4920bf49 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index f2bed54085..e0638f02d7 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -25,6 +25,17 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 0d8702f19e..0b35de2ed5 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -16,11 +16,6 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11'); } - public function update_schema() - { - return array(); - } - public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index cf067d2e2c..a7af5d052d 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -26,7 +26,9 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ), ), 'drop_keys' => array( - $this->table_prefix . 'groups' => array('group_legend'), + $this->table_prefix . 'groups' => array( + 'group_legend', + ), ), 'add_index' => array( $this->table_prefix . 'sessions' => array( @@ -52,12 +54,16 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ), 'add_index' => array( $this->table_prefix . 'groups' => array( - 'group_legend' => 'group_legend', + 'group_legend' => array('group_legend'), ), ), 'drop_keys' => array( - $this->table_prefix . 'sessions' => array('session_forum_id'), - $this->table_prefix . 'groups' => array('group_legend_name'), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name', + ), ), ); } diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 3469d8d178..19e9213262 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_2_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index d3c2200f14..7dd321d83c 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index 67fd1faec6..d73f9587c3 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -36,7 +36,9 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ), ), 'drop_keys' => array( - $this->table_prefix . 'sessions' => array('session_forum_id'), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), ), 'add_index' => array( $this->table_prefix . 'sessions' => array( @@ -46,6 +48,24 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array( + 'session_forum_id', + ), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index dff375f438..d671b0cac3 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_3_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 2320c4ac4b..9cce80be74 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -29,6 +29,21 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id', + 'template_inherit_path', + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index 1af4508331..e734814530 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_4_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index e9bb0e01f5..eb2fcb8d0e 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -55,6 +55,17 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 2f80970781..6d61793d08 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_5_rc1part2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 1fab0f8873..354de748c8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -18,10 +18,10 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { return array( 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), + $this->table_prefix . 'acl_options' => array('auth_option'), ), 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( + $this->table_prefix . 'acl_options' => array( 'auth_option' => array('auth_option'), ), ), diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index 26176b9437..cc6fccaae2 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc4'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index 35adcf52be..b520bda6d0 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -59,6 +59,46 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts', + ), + $this->table_prefix . 'users' => array( + 'user_new', + 'user_reminded', + 'user_reminded_time', + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth', + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported', + ), + $this->table_prefix . 'reports' => array( + 'pm_id', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt', + ), + $this->table_prefix . 'forums' => array( + 'forum_options', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'reports' => array( + 'post_id', + 'pm_id', + ), + $this->table_prefix . 'posts' => array( + 'post_username', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index 4092a5fa61..d61c296445 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index ec22d1da77..a3f0dcacdf 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index e748c7a4ff..3855b85551 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index f27b56f778..59779c9cb0 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index 5543d6437a..5570a5dc06 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index 71584382e8..84b8f798a8 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -18,7 +18,9 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { return array( 'drop_keys' => array( - $this->table_prefix . 'log' => array('log_time'), + $this->table_prefix . 'log' => array( + 'log_time', + ), ), 'add_index' => array( $this->table_prefix . 'topics_track' => array( @@ -28,6 +30,22 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'log' => array( + 'log_time' => array('log_time'), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index 4e380c810d..48aa818ba3 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index a5defc8278..d94fe869fb 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_8_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 78db06b512..eb4cc5bd1a 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_pl1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index eb359e2697..d19a24b45e 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc4'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index ea49cdbba9..4ed48061a4 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -51,6 +51,15 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'login_attempts', + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index e3c4716665..98ef232cb4 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index 3cdecb96ae..b84d61031e 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index c2a92e618a..2a00bba843 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 2771d82d83..4f7ed07158 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -15,7 +15,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration 'phpbb_db_migration_data_3_0_11', 'phpbb_db_migration_data_extensions', 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone', + 'phpbb_db_migration_data_timezone_p2', ); } @@ -23,32 +23,57 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { return array( 'add_columns' => array( - GROUPS_TABLE => array( + $this->table_prefix . 'groups' => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), - PROFILE_FIELDS_TABLE => array( + $this->table_prefix . 'profile_fields' => array( 'field_show_on_pm' => array('BOOL', 0), ), - STYLES_TABLE => array( + $this->table_prefix . 'styles' => array( 'style_path' => array('VCHAR:100', ''), 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), 'style_parent_id' => array('UINT:4', 0), 'style_parent_tree' => array('TEXT', ''), ), - REPORTS_TABLE => array( + $this->table_prefix . 'reports' => array( 'reported_post_text' => array('MTEXT_UNI', ''), 'reported_post_uid' => array('VCHAR:8', ''), 'reported_post_bitfield' => array('VCHAR:255', ''), ), ), 'change_columns' => array( - GROUPS_TABLE => array( + $this->table_prefix . 'groups' => array( 'group_legend' => array('UINT', 0), ), ), ); } + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'groups' => array( + 'group_teampage', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_pm', + ), + $this->table_prefix . 'styles' => array( + 'style_path', + 'bbcode_bitfield', + 'style_parent_id', + 'style_parent_tree', + ), + $this->table_prefix . 'reports' => array( + 'reported_post_text', + 'reported_post_uid', + 'reported_post_bitfield', + ), + ), + ); + } + public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index b8379483a3..b5f5b792cf 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { return array( 'add_tables' => array( - EXT_TABLE => array( + $this->table_prefix . 'ext' => array( 'COLUMNS' => array( 'ext_name' => array('VCHAR', ''), 'ext_active' => array('BOOL', 0), @@ -32,6 +32,15 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration ); } + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'ext', + ), + ); + } + public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index 387b37de8e..f1b26f525a 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11'); } - public function update_schema() - { - return array(); - } - public function update_data() { return array( @@ -47,10 +42,10 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration } // Get all installed styles - if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + if ($this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset')) { $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . 'styles_theme c, ' . $this->table_prefix . "styles_imageset i WHERE t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; @@ -58,7 +53,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration else { $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c WHERE t.template_id = s.template_id AND c.theme_id = s.theme_id"; } diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index db4b7f1753..361eb5a389 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { return array( 'drop_columns' => array( - STYLES_TABLE => array( + $this->table_prefix . 'styles' => array( 'imageset_id', 'template_id', 'theme_id', @@ -26,17 +26,99 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration ), 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, + $this->table_prefix . 'styles_imageset', + $this->table_prefix . 'styles_imageset_data', + $this->table_prefix . 'styles_template', + $this->table_prefix . 'styles_template_data', + $this->table_prefix . 'styles_theme', ), ); } - public function update_data() + public function revert_schema() { - return array(); + return array( + 'add_columns' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id' => array('UINT', 0), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + ), + ), + + 'add_tables' => array( + $this->table_prefix . 'styles_imageset' => array( + 'COLUMNS' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_name' => array('VCHAR_UNI:255', ''), + 'imageset_copyright' => array('VCHAR_UNI', ''), + 'imageset_path' => array('VCHAR:100', ''), + ), + 'PRIMARY_KEY' => 'imageset_id', + 'KEYS' => array( + 'imgset_nm' => array('UNIQUE', 'imageset_name'), + ), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'COLUMNS' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'image_name' => array('VCHAR:200', ''), + 'image_filename' => array('VCHAR:200', ''), + 'image_lang' => array('VCHAR:30', ''), + 'image_height' => array('USINT', 0), + 'image_width' => array('USINT', 0), + 'imageset_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'image_id', + 'KEYS' => array( + 'i_d' => array('INDEX', 'imageset_id'), + ), + ), + $this->table_prefix . 'styles_template' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + 'template_name' => array('VCHAR_UNI:255', ''), + 'template_copyright' => array('VCHAR_UNI', ''), + 'template_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'template_storedb' => array('BOOL', 0), + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'template_id', + 'KEYS' => array( + 'tmplte_nm' => array('UNIQUE', 'template_name'), + ), + ), + $this->table_prefix . 'styles_template_data' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', 0), + 'template_filename' => array('VCHAR:100', ''), + 'template_included' => array('TEXT', ''), + 'template_mtime' => array('TIMESTAMP', 0), + 'template_data' => array('MTEXT_UNI', ''), + ), + 'KEYS' => array( + 'tid' => array('INDEX', 'template_id'), + 'tfn' => array('INDEX', 'template_filename'), + ), + ), + $this->table_prefix . 'styles_theme' => array( + 'COLUMNS' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + 'theme_name' => array('VCHAR_UNI:255', ''), + 'theme_copyright' => array('VCHAR_UNI', ''), + 'theme_path' => array('VCHAR:100', ''), + 'theme_storedb' => array('BOOL', 0), + 'theme_mtime' => array('TIMESTAMP', 0), + 'theme_data' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'theme_id', + 'KEYS' => array( + 'theme_name' => array('UNIQUE', 'theme_name'), + ), + ), + ), + ); } } diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 7734ed4b76..1a7dfe1e19 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { return array( 'change_columns' => array( - USERS_TABLE => array( + $this->table_prefix . 'users' => array( 'user_timezone' => array('VCHAR:100', ''), ), ), @@ -36,13 +36,13 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { // Update user timezones $sql = 'SELECT user_dst, user_timezone - FROM ' . USERS_TABLE . ' + FROM ' . $this->table_prefix . 'users GROUP BY user_timezone, user_dst'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $sql = 'UPDATE ' . USERS_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "users SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' AND user_dst = " . (int) $row['user_dst']; @@ -51,13 +51,10 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration $this->db->sql_freeresult($result); // Update board default timezone - $sql = 'UPDATE ' . CONFIG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "config SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' WHERE config_name = 'board_timezone'"; $this->sql_query($sql); - - // After we have calculated the timezones we can delete user_dst column from user table. - $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } /** diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php new file mode 100644 index 0000000000..85c1cf9456 --- /dev/null +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -0,0 +1,38 @@ + array( + $this->table_prefix . 'users' => array( + 'user_dst', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst' => array('BOOL', 0), + ), + ), + ); + } +} -- cgit v1.2.1 From 74f4397451dae0ab83d977d97d96ed9549bf3ab9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 22:28:48 -0600 Subject: [feature/migrations] Make depends_on static to call it without dependencies Move installing migrations to migration/install.php and handle figuring out what migrations have been installed based on phpBB version. PHPBB3-11318 --- phpBB/includes/db/migration/data/3_0_1.php | 4 +- phpBB/includes/db/migration/data/3_0_10.php | 4 +- phpBB/includes/db/migration/data/3_0_10_rc1.php | 4 +- phpBB/includes/db/migration/data/3_0_10_rc2.php | 4 +- phpBB/includes/db/migration/data/3_0_10_rc3.php | 4 +- phpBB/includes/db/migration/data/3_0_11.php | 4 +- phpBB/includes/db/migration/data/3_0_11_rc1.php | 8 +- phpBB/includes/db/migration/data/3_0_11_rc2.php | 8 +- phpBB/includes/db/migration/data/3_0_12_rc1.php | 2 +- phpBB/includes/db/migration/data/3_0_1_rc1.php | 15 +-- phpBB/includes/db/migration/data/3_0_2.php | 4 +- phpBB/includes/db/migration/data/3_0_2_rc1.php | 4 +- phpBB/includes/db/migration/data/3_0_2_rc2.php | 8 +- phpBB/includes/db/migration/data/3_0_3.php | 4 +- phpBB/includes/db/migration/data/3_0_3_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_4.php | 6 +- phpBB/includes/db/migration/data/3_0_4_rc1.php | 10 +- phpBB/includes/db/migration/data/3_0_5.php | 4 +- phpBB/includes/db/migration/data/3_0_5_rc1.php | 12 +- .../includes/db/migration/data/3_0_5_rc1part2.php | 6 +- phpBB/includes/db/migration/data/3_0_6.php | 4 +- phpBB/includes/db/migration/data/3_0_6_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_6_rc2.php | 4 +- phpBB/includes/db/migration/data/3_0_6_rc3.php | 6 +- phpBB/includes/db/migration/data/3_0_6_rc4.php | 4 +- phpBB/includes/db/migration/data/3_0_7.php | 4 +- phpBB/includes/db/migration/data/3_0_7_pl1.php | 4 +- phpBB/includes/db/migration/data/3_0_7_rc1.php | 10 +- phpBB/includes/db/migration/data/3_0_7_rc2.php | 6 +- phpBB/includes/db/migration/data/3_0_8.php | 4 +- phpBB/includes/db/migration/data/3_0_8_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_9.php | 4 +- phpBB/includes/db/migration/data/3_0_9_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_9_rc2.php | 4 +- phpBB/includes/db/migration/data/3_0_9_rc3.php | 4 +- phpBB/includes/db/migration/data/3_0_9_rc4.php | 4 +- phpBB/includes/db/migration/data/3_1_0_dev.php | 2 +- phpBB/includes/db/migration/data/extensions.php | 2 +- .../includes/db/migration/data/style_update_p1.php | 2 +- .../includes/db/migration/data/style_update_p2.php | 2 +- phpBB/includes/db/migration/data/timezone.php | 2 +- phpBB/includes/db/migration/data/timezone_p2.php | 2 +- phpBB/includes/db/migration/install.php | 129 +++++++++++++++++++++ 43 files changed, 245 insertions(+), 121 deletions(-) create mode 100644 phpBB/includes/db/migration/install.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index d71288c64b..a9eac6f110 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.1')), diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 17472562f2..89afb8a432 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10')), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index eebee44e39..ca8fadec61 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9'); } - function update_data() + public function update_data() { return array( array('config.add', array('email_max_chunk_size', 50)), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index b81fde9bcb..1f39ea48e0 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index d97b0b4aec..cd82bb573e 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10-rc3')), diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index b149cd374c..9f25f0e489 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.11')), diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 3d4920bf49..676e6baa87 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), @@ -24,7 +24,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration ); } - function cleanup_deactivated_styles() + public function cleanup_deactivated_styles() { // Updates users having current style a deactivated one $sql = 'SELECT style_id @@ -48,7 +48,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration } } - function delete_orphan_private_messages() + public function delete_orphan_private_messages() { // Delete orphan private messages $batch_size = 500; diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index e0638f02d7..e5bb3e44a6 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc1'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -25,7 +25,7 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -36,7 +36,7 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.11-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 0b35de2ed5..4fe0828716 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index a7af5d052d..9f1c04809d 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -9,12 +9,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { - function depends_on() - { - return array(); - } - - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -41,7 +36,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -68,7 +63,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'fix_unset_last_view_time'))), @@ -78,7 +73,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function fix_unset_last_view_time() + public function fix_unset_last_view_time() { $sql = 'UPDATE ' . $this->table_prefix . "topics SET topic_last_view_time = topic_last_post_time @@ -86,7 +81,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function reset_smiley_size() + public function reset_smiley_size() { // Update smiley sizes $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 19e9213262..8661578281 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.2')), diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index 7dd321d83c..851060c3b5 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1'); } - function update_data() + public function update_data() { return array( array('config.add', array('referer_validation', '1')), diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index d73f9587c3..c255e55aef 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc1'); } - function update_schema() + public function update_schema() { return array( 'change_columns' => array( @@ -48,7 +48,7 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'add_index' => array( @@ -66,7 +66,7 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.2-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index d671b0cac3..2873c798fd 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.3')), diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 9cce80be74..49e4170c3f 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -29,7 +29,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -44,7 +44,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('enable_queue_trigger', '0')), @@ -59,7 +59,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function correct_acp_email_permissions() + public function correct_acp_email_permissions() { $sql = 'UPDATE ' . $this->table_prefix . 'modules SET module_auth = \'acl_a_email && cfg_email_enable\' @@ -68,7 +68,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function set_group_default_max_recipients() + public function set_group_default_max_recipients() { // Set maximum number of recipients for the registered users, bots, guests group $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index e734814530..590ae3c69f 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4_rc1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'rename_log_delete_topic'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration ); } - function rename_log_delete_topic() + public function rename_log_delete_topic() { if ($this->db->sql_layer == 'oracle') { diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index eb2fcb8d0e..8f44baf046 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -55,7 +55,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -66,7 +66,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_custom_profile_fields'))), @@ -75,7 +75,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function update_custom_profile_fields() + public 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 diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 6d61793d08..65b292207e 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1part2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.5')), diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php index cbf28c0be6..a0893a0dbb 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4'); } - function update_schema() + public function update_schema() { return array( 'change_columns' => array( @@ -25,7 +25,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { $search_indexing_state = $this->config['search_indexing_state']; @@ -42,7 +42,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration ); } - function hash_old_passwords() + public function hash_old_passwords() { $sql = 'SELECT user_id, user_password FROM ' . $this->table_prefix . 'users @@ -63,7 +63,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function update_ichiro_bot() + public function update_ichiro_bot() { // Adjust bot entry $sql = 'UPDATE ' . $this->table_prefix . "bots @@ -72,7 +72,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function remove_duplicate_auth_options() + public function remove_duplicate_auth_options() { // Before we are able to add a unique key to auth_option, we need to remove duplicate entries $sql = 'SELECT auth_option diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 354de748c8..0597fc0ff8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1'); } - function update_schema() + public function update_schema() { return array( 'drop_keys' => array( @@ -28,7 +28,7 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.5-rc1')), diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index cc6fccaae2..a7b88e510a 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc4'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6')), diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index b520bda6d0..5ebeceeed7 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -59,7 +59,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -99,7 +99,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), @@ -184,14 +184,14 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function set_user_options_default() + public function set_user_options_default() { // 229376 is the added value to enable all three signature options $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; $this->sql_query($sql); } - function add_newly_registered_group() + public function add_newly_registered_group() { // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) $sql = 'SELECT group_id diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index d61c296445..7cbda4c616 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index a3f0dcacdf..209057ec70 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc2'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_cp_fields'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration ); } - function update_cp_fields() + public function update_cp_fields() { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index 3855b85551..62f0e91a7d 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6-rc4')), diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index 59779c9cb0..3e215ff905 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.7')), diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index 5570a5dc06..ffe0836d02 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.7-pl1')), diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index 84b8f798a8..b30830c21d 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6'); } - function update_schema() + public function update_schema() { return array( 'drop_keys' => array( @@ -30,7 +30,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'add_index' => array( @@ -46,7 +46,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('feed_overall', 1)), @@ -61,7 +61,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function delete_text_templates() + public function delete_text_templates() { // Delete all text-templates from the template_data $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index 48aa818ba3..e986be23bf 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_email_hash'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration ); } - function update_email_hash($start = 0) + public function update_email_hash($start = 0) { $limit = 1000; diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index d94fe869fb..8043b934b0 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.8')), diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index eb4cc5bd1a..8214f44f17 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_pl1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_file_extension_group_names'))), @@ -37,7 +37,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration ); } - function update_file_extension_group_names() + public function update_file_extension_group_names() { // Update file extension group names to use language strings. $sql = 'SELECT lang_dir @@ -93,7 +93,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function update_module_auth() + public function update_module_auth() { $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' @@ -103,7 +103,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function update_bots() + public function update_bots() { $bot_name = 'Bing [Bot]'; $bot_name_clean = utf8_clean_string($bot_name); @@ -167,7 +167,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration } } - function delete_orphan_shadow_topics() + public function delete_orphan_shadow_topics() { // Delete shadow topics pointing to not existing topics $batch_size = 500; diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index d19a24b45e..c562f1f2cf 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc4'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 4ed48061a4..367bb25734 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8'); } - function update_schema() + public function update_schema() { return array( 'add_tables' => array( @@ -51,7 +51,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_tables' => array( @@ -60,7 +60,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('ip_login_limit_max', 50)), @@ -73,7 +73,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function update_file_extension_group_names() + public function update_file_extension_group_names() { // Update file extension group names to use language strings, again. $sql = 'SELECT group_id, group_name @@ -95,7 +95,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function fix_firebird_qa_captcha() + public 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 diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index 98ef232cb4..c8566d54a5 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index b84d61031e..da977e9666 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc3')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index 2a00bba843..0bfe26985c 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc4')), diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 4f7ed07158..14953591d1 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array( 'phpbb_db_migration_data_3_0_11', diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index b5f5b792cf..ff54d0d933 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index f1b26f525a..701afc0d78 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index 361eb5a389..1a8cc9da58 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_style_update_p1'); } diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 1a7dfe1e19..3658120629 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php index 85c1cf9456..15f1a3e414 100644 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_timezone'); } diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php new file mode 100644 index 0000000000..af2ba392b1 --- /dev/null +++ b/phpBB/includes/db/migration/install.php @@ -0,0 +1,129 @@ + 'phpbb_db_migration_data_3_0_1_rc1', + '3.0.1' => 'phpbb_db_migration_data_3_0_1', + '3.0.2-rc1' => 'phpbb_db_migration_data_3_0_2_rc1', + '3.0.2-rc2' => 'phpbb_db_migration_data_3_0_2_rc2', + '3.0.2' => 'phpbb_db_migration_data_3_0_2', + '3.0.3-rc1' => 'phpbb_db_migration_data_3_0_3_rc1', + '3.0.3' => 'phpbb_db_migration_data_3_0_3', + '3.0.4-rc1' => 'phpbb_db_migration_data_3_0_4_rc1', + '3.0.4' => 'phpbb_db_migration_data_3_0_4', + '3.0.5-rc1' => array( + 'phpbb_db_migration_data_3_0_5_rc1', + 'phpbb_db_migration_data_3_0_5_rc1part2', + ), + '3.0.5' => 'phpbb_db_migration_data_3_0_5', + '3.0.6-rc1' => 'phpbb_db_migration_data_3_0_6_rc1', + '3.0.6-rc2' => 'phpbb_db_migration_data_3_0_6_rc2', + '3.0.6-rc3' => 'phpbb_db_migration_data_3_0_6_rc3', + '3.0.6-rc4' => 'phpbb_db_migration_data_3_0_6_rc4', + '3.0.6' => 'phpbb_db_migration_data_3_0_6', + '3.0.7-rc1' => 'phpbb_db_migration_data_3_0_7_rc1', + '3.0.7-rc2' => 'phpbb_db_migration_data_3_0_7_rc2', + '3.0.7' => 'phpbb_db_migration_data_3_0_7', + '3.0.7-pl1' => 'phpbb_db_migration_data_3_0_7_pl1', + '3.0.8-rc1' => 'phpbb_db_migration_data_3_0_8_rc1', + '3.0.8' => 'phpbb_db_migration_data_3_0_8', + '3.0.9-rc1' => 'phpbb_db_migration_data_3_0_9_rc1', + '3.0.9-rc2' => 'phpbb_db_migration_data_3_0_9_rc2', + '3.0.9-rc3' => 'phpbb_db_migration_data_3_0_9_rc3', + '3.0.9-rc4' => 'phpbb_db_migration_data_3_0_9_rc4', + '3.0.9' => 'phpbb_db_migration_data_3_0_9', + '3.0.10-rc1' => 'phpbb_db_migration_data_3_0_10_rc1', + '3.0.10-rc2' => 'phpbb_db_migration_data_3_0_10_rc2', + '3.0.10-rc3' => 'phpbb_db_migration_data_3_0_10_rc3', + '3.0.10' => 'phpbb_db_migration_data_3_0_10', + '3.0.11-rc1' => 'phpbb_db_migration_data_3_0_11_rc1', + '3.0.11-rc2' => 'phpbb_db_migration_data_3_0_11_rc2', + '3.0.11' => 'phpbb_db_migration_data_3_0_11', + '3.0.12-rc1' => 'phpbb_db_migration_data_3_0_12_rc1', + '3.1.0-dev' => array( + 'phpbb_db_migration_data_style_update_p1', + 'phpbb_db_migration_data_style_update_p2', + 'phpbb_db_migration_data_timezone', + 'phpbb_db_migration_data_timezone_p2', + 'phpbb_db_migration_data_extensions', + 'phpbb_db_migration_data_3_1_0_dev', + ), + ); + + public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) + { + $this->create_table($db_tools); + + $this->guess_installed_migrations($db, $table_prefix, $version); + } + + protected function create_table(phpbb_db_tools $db_tools) + { + if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) + { + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); + } + } + + /** + * Guess what migrations have been installed based on phpBB version + * + * @param mixed $version + */ + protected function guess_installed_migrations(phpbb_db_driver $db, $table_prefix, $version) + { + $installed = array(); + foreach ($this->version_to_migration as $compare => $migration_list) + { + if (version_compare($version, $compare, '<=')) + { + // The migration should have effectively been installed already + if (!is_array($migration_list)) + { + $migration_list = array($migration_list); + } + + foreach ($migration_list as $migration_name) + { + $sql_ary = array( + 'migration_name' => $migration_name, + 'migration_depends_on' => $migration_name::depends_on(), + 'migration_schema_done' => 1, + 'migration_data_done' => 1, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, + ); + $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . + $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + } + } + } + } +} -- cgit v1.2.1 From 8baceacc36f06c2c14d4a4c08cecb3c80b3c76d3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 22:45:26 -0600 Subject: [feature/migrations] Fix migrations installer, schema for schema_data.sql PHPBB3-11318 --- phpBB/includes/db/migration/install.php | 43 ++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php index af2ba392b1..95f3a3b994 100644 --- a/phpBB/includes/db/migration/install.php +++ b/phpBB/includes/db/migration/install.php @@ -66,16 +66,16 @@ class phpbb_db_migration_install public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) { - $this->create_table($db_tools); + $this->create_table($db_tools, $table_prefix); $this->guess_installed_migrations($db, $table_prefix, $version); } - protected function create_table(phpbb_db_tools $db_tools) + protected function create_table(phpbb_db_tools $db_tools, $table_prefix) { - if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) + if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + $db_tools->sql_create_table($table_prefix . 'migrations', array( 'COLUMNS' => array( 'migration_name' => array('VCHAR', ''), 'migration_depends_on' => array('TEXT', ''), @@ -100,7 +100,7 @@ class phpbb_db_migration_install $installed = array(); foreach ($this->version_to_migration as $compare => $migration_list) { - if (version_compare($version, $compare, '<=')) + if (version_compare($version, $compare, '>=')) { // The migration should have effectively been installed already if (!is_array($migration_list)) @@ -110,18 +110,27 @@ class phpbb_db_migration_install foreach ($migration_list as $migration_name) { - $sql_ary = array( - 'migration_name' => $migration_name, - 'migration_depends_on' => $migration_name::depends_on(), - 'migration_schema_done' => 1, - 'migration_data_done' => 1, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . - $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); + $sql = 'SELECT 1 FROM ' . $table_prefix . "migrations + WHERE migration_name = '" . $db->sql_escape($migration_name) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $sql_ary = array( + 'migration_name' => $migration_name, + 'migration_depends_on' => serialize($migration_name::depends_on()), + 'migration_schema_done' => 1, + 'migration_data_done' => 1, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, + ); + $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . + $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + } } } } -- cgit v1.2.1 From dfcf9966e95fce074a5ed6eb4036393f5b62de7c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 12 Jan 2013 19:45:20 -0600 Subject: [feature/migrations] Comments for the return in the custom functions PHPBB3-11318 --- phpBB/includes/db/migration/data/3_0_11_rc1.php | 1 + phpBB/includes/db/migration/data/3_0_7_rc2.php | 1 + 2 files changed, 2 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 676e6baa87..43e0156760 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -83,6 +83,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); $this->sql_query($sql); + // Return false to have the Migrator call this function again return false; } } diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index e986be23bf..c2720b532f 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -62,6 +62,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration return; } + // Return the next start, will be sent to $start when this function is called again return $start + $limit; } } -- cgit v1.2.1 From 5e69e1a7612a4dbe24620cc5cad33720cb0c2885 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 13 Jan 2013 13:23:02 -0600 Subject: [feature/migrations] effectively installed check for migration data PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 5 + phpBB/includes/db/migration/data/3_0_10.php | 5 + phpBB/includes/db/migration/data/3_0_10_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_10_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_10_rc3.php | 5 + phpBB/includes/db/migration/data/3_0_11.php | 5 + phpBB/includes/db/migration/data/3_0_11_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_11_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_12_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_1_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_2.php | 5 + phpBB/includes/db/migration/data/3_0_2_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_2_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_3.php | 5 + phpBB/includes/db/migration/data/3_0_3_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_4.php | 5 + phpBB/includes/db/migration/data/3_0_4_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_5.php | 5 + phpBB/includes/db/migration/data/3_0_5_rc1.php | 5 + .../includes/db/migration/data/3_0_5_rc1part2.php | 5 + phpBB/includes/db/migration/data/3_0_6.php | 5 + phpBB/includes/db/migration/data/3_0_6_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_6_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_6_rc3.php | 5 + phpBB/includes/db/migration/data/3_0_6_rc4.php | 5 + phpBB/includes/db/migration/data/3_0_7.php | 5 + phpBB/includes/db/migration/data/3_0_7_pl1.php | 5 + phpBB/includes/db/migration/data/3_0_7_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_7_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_8.php | 5 + phpBB/includes/db/migration/data/3_0_8_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_9.php | 5 + phpBB/includes/db/migration/data/3_0_9_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_9_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_9_rc3.php | 5 + phpBB/includes/db/migration/data/3_0_9_rc4.php | 5 + phpBB/includes/db/migration/data/3_1_0_dev.php | 5 + phpBB/includes/db/migration/data/extensions.php | 5 + .../includes/db/migration/data/style_update_p1.php | 5 + .../includes/db/migration/data/style_update_p2.php | 5 + phpBB/includes/db/migration/data/timezone.php | 5 + phpBB/includes/db/migration/data/timezone_p2.php | 5 + phpBB/includes/db/migration/install.php | 138 --------------------- 43 files changed, 210 insertions(+), 138 deletions(-) delete mode 100644 phpBB/includes/db/migration/install.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index a9eac6f110..8b7c6f0f7c 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 89afb8a432..b24a876bac 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc3'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index ca8fadec61..46b7db4e59 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index 1f39ea48e0..5e85467202 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index cd82bb573e..6ff81f7776 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index 9f25f0e489..1a63508593 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 43e0156760..19703bcc35 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10'); diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index e5bb3e44a6..219d44c4e0 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 4fe0828716..c23e8b24b8 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -11,6 +11,11 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.12-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index 9f1c04809d..2fc2849d04 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.1-rc1', '>='); + } + public function update_schema() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 8661578281..8aa975f779 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index 851060c3b5..6081cd682c 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1'); diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index c255e55aef..bb76c270d7 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index 2873c798fd..82039a109b 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 49e4170c3f..5e300962b7 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.3-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2'); diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index 590ae3c69f..34af9fa4ae 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index 8f44baf046..f63bebcf75 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.4-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3'); diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 65b292207e..077ed251d2 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1part2'); diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php index a0893a0dbb..df85ee4f7d 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4'); diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 0597fc0ff8..d2fad7a7f8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index a7b88e510a..1b0cbb1435 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc4'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index 5ebeceeed7..0f85084e65 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index 7cbda4c616..a9c497b3cd 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index 209057ec70..eca19fc2ff 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index 62f0e91a7d..19611d3c56 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc3'); diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index 3e215ff905..97cdf4e3f1 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index ffe0836d02..176854a8a6 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-pl1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7'); diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index b30830c21d..daf52213b9 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6'); diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index c2720b532f..8167d8fa40 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index 8043b934b0..25baaf0f07 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.8', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 8214f44f17..13e68a7953 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.8-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_pl1'); diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index c562f1f2cf..b35350dbb5 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc4'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 367bb25734..be6ced2566 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index c8566d54a5..0bec42a8de 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index da977e9666..a339670932 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index 0bfe26985c..ab5c302611 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc3'); diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 14953591d1..ac8882cb3a 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.1.0-dev', '>='); + } + static public function depends_on() { return array( diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index ff54d0d933..f077741883 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { + public function effectively_installed() + { + return $this->db_tools->sql_table_exists($this->table_prefix . 'ext'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index 701afc0d78..7506b7c49b 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index 1a8cc9da58..ef13f45d9b 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + static public function depends_on() { return array('phpbb_db_migration_data_style_update_p1'); diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 3658120629..66085b8872 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php index 15f1a3e414..38347a0c63 100644 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + static public function depends_on() { return array('phpbb_db_migration_data_timezone'); diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php deleted file mode 100644 index 95f3a3b994..0000000000 --- a/phpBB/includes/db/migration/install.php +++ /dev/null @@ -1,138 +0,0 @@ - 'phpbb_db_migration_data_3_0_1_rc1', - '3.0.1' => 'phpbb_db_migration_data_3_0_1', - '3.0.2-rc1' => 'phpbb_db_migration_data_3_0_2_rc1', - '3.0.2-rc2' => 'phpbb_db_migration_data_3_0_2_rc2', - '3.0.2' => 'phpbb_db_migration_data_3_0_2', - '3.0.3-rc1' => 'phpbb_db_migration_data_3_0_3_rc1', - '3.0.3' => 'phpbb_db_migration_data_3_0_3', - '3.0.4-rc1' => 'phpbb_db_migration_data_3_0_4_rc1', - '3.0.4' => 'phpbb_db_migration_data_3_0_4', - '3.0.5-rc1' => array( - 'phpbb_db_migration_data_3_0_5_rc1', - 'phpbb_db_migration_data_3_0_5_rc1part2', - ), - '3.0.5' => 'phpbb_db_migration_data_3_0_5', - '3.0.6-rc1' => 'phpbb_db_migration_data_3_0_6_rc1', - '3.0.6-rc2' => 'phpbb_db_migration_data_3_0_6_rc2', - '3.0.6-rc3' => 'phpbb_db_migration_data_3_0_6_rc3', - '3.0.6-rc4' => 'phpbb_db_migration_data_3_0_6_rc4', - '3.0.6' => 'phpbb_db_migration_data_3_0_6', - '3.0.7-rc1' => 'phpbb_db_migration_data_3_0_7_rc1', - '3.0.7-rc2' => 'phpbb_db_migration_data_3_0_7_rc2', - '3.0.7' => 'phpbb_db_migration_data_3_0_7', - '3.0.7-pl1' => 'phpbb_db_migration_data_3_0_7_pl1', - '3.0.8-rc1' => 'phpbb_db_migration_data_3_0_8_rc1', - '3.0.8' => 'phpbb_db_migration_data_3_0_8', - '3.0.9-rc1' => 'phpbb_db_migration_data_3_0_9_rc1', - '3.0.9-rc2' => 'phpbb_db_migration_data_3_0_9_rc2', - '3.0.9-rc3' => 'phpbb_db_migration_data_3_0_9_rc3', - '3.0.9-rc4' => 'phpbb_db_migration_data_3_0_9_rc4', - '3.0.9' => 'phpbb_db_migration_data_3_0_9', - '3.0.10-rc1' => 'phpbb_db_migration_data_3_0_10_rc1', - '3.0.10-rc2' => 'phpbb_db_migration_data_3_0_10_rc2', - '3.0.10-rc3' => 'phpbb_db_migration_data_3_0_10_rc3', - '3.0.10' => 'phpbb_db_migration_data_3_0_10', - '3.0.11-rc1' => 'phpbb_db_migration_data_3_0_11_rc1', - '3.0.11-rc2' => 'phpbb_db_migration_data_3_0_11_rc2', - '3.0.11' => 'phpbb_db_migration_data_3_0_11', - '3.0.12-rc1' => 'phpbb_db_migration_data_3_0_12_rc1', - '3.1.0-dev' => array( - 'phpbb_db_migration_data_style_update_p1', - 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone', - 'phpbb_db_migration_data_timezone_p2', - 'phpbb_db_migration_data_extensions', - 'phpbb_db_migration_data_3_1_0_dev', - ), - ); - - public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) - { - $this->create_table($db_tools, $table_prefix); - - $this->guess_installed_migrations($db, $table_prefix, $version); - } - - protected function create_table(phpbb_db_tools $db_tools, $table_prefix) - { - if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) - { - $db_tools->sql_create_table($table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); - } - } - - /** - * Guess what migrations have been installed based on phpBB version - * - * @param mixed $version - */ - protected function guess_installed_migrations(phpbb_db_driver $db, $table_prefix, $version) - { - $installed = array(); - foreach ($this->version_to_migration as $compare => $migration_list) - { - if (version_compare($version, $compare, '>=')) - { - // The migration should have effectively been installed already - if (!is_array($migration_list)) - { - $migration_list = array($migration_list); - } - - foreach ($migration_list as $migration_name) - { - $sql = 'SELECT 1 FROM ' . $table_prefix . "migrations - WHERE migration_name = '" . $db->sql_escape($migration_name) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql_ary = array( - 'migration_name' => $migration_name, - 'migration_depends_on' => serialize($migration_name::depends_on()), - 'migration_schema_done' => 1, - 'migration_data_done' => 1, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . - $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - } - } - } - } -} -- cgit v1.2.1 From 747e51491859507ad2f1891df5df4e563c23dd57 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 14 Jan 2013 12:38:14 -0600 Subject: [feature/migrations] Reports table schema changes in recent develop PHPBB3-9737 --- phpBB/includes/db/migration/data/3_1_0_dev.php | 1 + .../db/migration/data/reported_posts_display.php | 42 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 phpBB/includes/db/migration/data/reported_posts_display.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index ac8882cb3a..8b437104e0 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -21,6 +21,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration 'phpbb_db_migration_data_extensions', 'phpbb_db_migration_data_style_update_p2', 'phpbb_db_migration_data_timezone_p2', + 'phpbb_db_migration_data_reported_posts_display', ); } diff --git a/phpBB/includes/db/migration/data/reported_posts_display.php b/phpBB/includes/db/migration/data/reported_posts_display.php new file mode 100644 index 0000000000..fa605e28e5 --- /dev/null +++ b/phpBB/includes/db/migration/data/reported_posts_display.php @@ -0,0 +1,42 @@ +db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode', + 'reported_post_enable_smilies', + 'reported_post_enable_magic_url', + ), + ), + ); + } +} -- cgit v1.2.1 From 58507f250bf11dda6a138d5f66057ec413750e03 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 14 Jan 2013 12:45:01 -0600 Subject: [feature/migrations] Subdirectories for migration data Organization will set you free PHPBB3-9737 --- phpBB/includes/db/migration/data/30x/3_0_1.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_10.php | 28 ++ .../includes/db/migration/data/30x/3_0_10_rc1.php | 30 ++ .../includes/db/migration/data/30x/3_0_10_rc2.php | 28 ++ .../includes/db/migration/data/30x/3_0_10_rc3.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_11.php | 28 ++ .../includes/db/migration/data/30x/3_0_11_rc1.php | 95 +++++ .../includes/db/migration/data/30x/3_0_11_rc2.php | 50 +++ .../includes/db/migration/data/30x/3_0_12_rc1.php | 123 +++++++ phpBB/includes/db/migration/data/30x/3_0_1_rc1.php | 108 ++++++ phpBB/includes/db/migration/data/30x/3_0_2.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_2_rc1.php | 32 ++ phpBB/includes/db/migration/data/30x/3_0_2_rc2.php | 80 ++++ phpBB/includes/db/migration/data/30x/3_0_3.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_3_rc1.php | 83 +++++ phpBB/includes/db/migration/data/30x/3_0_4.php | 49 +++ phpBB/includes/db/migration/data/30x/3_0_4_rc1.php | 123 +++++++ phpBB/includes/db/migration/data/30x/3_0_5.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_5_rc1.php | 124 +++++++ .../db/migration/data/30x/3_0_5_rc1part2.php | 42 +++ phpBB/includes/db/migration/data/30x/3_0_6.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_6_rc1.php | 324 ++++++++++++++++ phpBB/includes/db/migration/data/30x/3_0_6_rc2.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_6_rc3.php | 40 ++ phpBB/includes/db/migration/data/30x/3_0_6_rc4.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_7.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_7_pl1.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_7_rc1.php | 76 ++++ phpBB/includes/db/migration/data/30x/3_0_7_rc2.php | 73 ++++ phpBB/includes/db/migration/data/30x/3_0_8.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_8_rc1.php | 221 +++++++++++ phpBB/includes/db/migration/data/30x/3_0_9.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_9_rc1.php | 124 +++++++ phpBB/includes/db/migration/data/30x/3_0_9_rc2.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_9_rc3.php | 28 ++ phpBB/includes/db/migration/data/30x/3_0_9_rc4.php | 28 ++ phpBB/includes/db/migration/data/310/dev.php | 406 +++++++++++++++++++++ .../includes/db/migration/data/310/extensions.php | 69 ++++ .../migration/data/310/reported_posts_display.php | 42 +++ .../db/migration/data/310/style_update_p1.php | 157 ++++++++ .../db/migration/data/310/style_update_p2.php | 129 +++++++ phpBB/includes/db/migration/data/310/timezone.php | 163 +++++++++ .../includes/db/migration/data/310/timezone_p2.php | 43 +++ phpBB/includes/db/migration/data/3_0_1.php | 28 -- phpBB/includes/db/migration/data/3_0_10.php | 28 -- phpBB/includes/db/migration/data/3_0_10_rc1.php | 30 -- phpBB/includes/db/migration/data/3_0_10_rc2.php | 28 -- phpBB/includes/db/migration/data/3_0_10_rc3.php | 28 -- phpBB/includes/db/migration/data/3_0_11.php | 28 -- phpBB/includes/db/migration/data/3_0_11_rc1.php | 95 ----- phpBB/includes/db/migration/data/3_0_11_rc2.php | 50 --- phpBB/includes/db/migration/data/3_0_12_rc1.php | 123 ------- phpBB/includes/db/migration/data/3_0_1_rc1.php | 108 ------ phpBB/includes/db/migration/data/3_0_2.php | 28 -- phpBB/includes/db/migration/data/3_0_2_rc1.php | 32 -- phpBB/includes/db/migration/data/3_0_2_rc2.php | 80 ---- phpBB/includes/db/migration/data/3_0_3.php | 28 -- phpBB/includes/db/migration/data/3_0_3_rc1.php | 83 ----- phpBB/includes/db/migration/data/3_0_4.php | 49 --- phpBB/includes/db/migration/data/3_0_4_rc1.php | 123 ------- phpBB/includes/db/migration/data/3_0_5.php | 28 -- phpBB/includes/db/migration/data/3_0_5_rc1.php | 124 ------- .../includes/db/migration/data/3_0_5_rc1part2.php | 42 --- phpBB/includes/db/migration/data/3_0_6.php | 28 -- phpBB/includes/db/migration/data/3_0_6_rc1.php | 324 ---------------- phpBB/includes/db/migration/data/3_0_6_rc2.php | 28 -- phpBB/includes/db/migration/data/3_0_6_rc3.php | 40 -- phpBB/includes/db/migration/data/3_0_6_rc4.php | 28 -- phpBB/includes/db/migration/data/3_0_7.php | 28 -- phpBB/includes/db/migration/data/3_0_7_pl1.php | 28 -- phpBB/includes/db/migration/data/3_0_7_rc1.php | 76 ---- phpBB/includes/db/migration/data/3_0_7_rc2.php | 73 ---- phpBB/includes/db/migration/data/3_0_8.php | 28 -- phpBB/includes/db/migration/data/3_0_8_rc1.php | 221 ----------- phpBB/includes/db/migration/data/3_0_9.php | 28 -- phpBB/includes/db/migration/data/3_0_9_rc1.php | 124 ------- phpBB/includes/db/migration/data/3_0_9_rc2.php | 28 -- phpBB/includes/db/migration/data/3_0_9_rc3.php | 28 -- phpBB/includes/db/migration/data/3_0_9_rc4.php | 28 -- phpBB/includes/db/migration/data/3_1_0_dev.php | 406 --------------------- phpBB/includes/db/migration/data/extensions.php | 69 ---- .../db/migration/data/reported_posts_display.php | 42 --- .../includes/db/migration/data/style_update_p1.php | 157 -------- .../includes/db/migration/data/style_update_p2.php | 129 ------- phpBB/includes/db/migration/data/timezone.php | 163 --------- phpBB/includes/db/migration/data/timezone_p2.php | 43 --- 86 files changed, 3310 insertions(+), 3310 deletions(-) create mode 100644 phpBB/includes/db/migration/data/30x/3_0_1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_10.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_10_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_10_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_10_rc3.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_11.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_11_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_11_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_12_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_1_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_2_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_2_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_3.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_3_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_4.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_4_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_5.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_5_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_6.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_6_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_6_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_6_rc3.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_6_rc4.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_7.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_7_pl1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_7_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_7_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_8.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_8_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_9.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_9_rc1.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_9_rc2.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_9_rc3.php create mode 100644 phpBB/includes/db/migration/data/30x/3_0_9_rc4.php create mode 100644 phpBB/includes/db/migration/data/310/dev.php create mode 100644 phpBB/includes/db/migration/data/310/extensions.php create mode 100644 phpBB/includes/db/migration/data/310/reported_posts_display.php create mode 100644 phpBB/includes/db/migration/data/310/style_update_p1.php create mode 100644 phpBB/includes/db/migration/data/310/style_update_p2.php create mode 100644 phpBB/includes/db/migration/data/310/timezone.php create mode 100644 phpBB/includes/db/migration/data/310/timezone_p2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_12_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_1_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_3_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_4.php delete mode 100644 phpBB/includes/db/migration/data/3_0_4_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1part2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc4.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_pl1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_8.php delete mode 100644 phpBB/includes/db/migration/data/3_0_8_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc4.php delete mode 100644 phpBB/includes/db/migration/data/3_1_0_dev.php delete mode 100644 phpBB/includes/db/migration/data/extensions.php delete mode 100644 phpBB/includes/db/migration/data/reported_posts_display.php delete mode 100644 phpBB/includes/db/migration/data/style_update_p1.php delete mode 100644 phpBB/includes/db/migration/data/style_update_p2.php delete mode 100644 phpBB/includes/db/migration/data/timezone.php delete mode 100644 phpBB/includes/db/migration/data/timezone_p2.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/30x/3_0_1.php b/phpBB/includes/db/migration/data/30x/3_0_1.php new file mode 100644 index 0000000000..c996a0138a --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_1.php @@ -0,0 +1,28 @@ +config['version'], '3.0.1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_1_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_10.php b/phpBB/includes/db/migration/data/30x/3_0_10.php new file mode 100644 index 0000000000..122f93d6b4 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_10.php @@ -0,0 +1,28 @@ +config['version'], '3.0.10', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_10_rc3'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.10')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php new file mode 100644 index 0000000000..0ed05812dc --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php @@ -0,0 +1,30 @@ +config['version'], '3.0.10-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_9'); + } + + public function update_data() + { + return array( + array('config.add', array('email_max_chunk_size', 50)), + + array('config.update', array('version', '3.0.10-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php new file mode 100644 index 0000000000..b14b3b00aa --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php @@ -0,0 +1,28 @@ +config['version'], '3.0.10-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_10_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.10-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php new file mode 100644 index 0000000000..473057d65d --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php @@ -0,0 +1,28 @@ +config['version'], '3.0.10-rc3', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_10_rc2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.10-rc3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_11.php b/phpBB/includes/db/migration/data/30x/3_0_11.php new file mode 100644 index 0000000000..e063c699cc --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_11.php @@ -0,0 +1,28 @@ +config['version'], '3.0.11', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11_rc2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.11')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php new file mode 100644 index 0000000000..dddfc0e0e7 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php @@ -0,0 +1,95 @@ +config['version'], '3.0.11-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_10'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), + array('custom', array(array(&$this, 'delete_orphan_private_messages'))), + + array('config.update', array('version', '3.0.11-rc1')), + ); + } + + public function cleanup_deactivated_styles() + { + // Updates users having current style a deactivated one + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 0'; + $result = $this->sql_query($sql); + + $deactivated_style_ids = array(); + while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) + { + $deactivated_style_ids[] = (int) $style_id; + } + $this->db->sql_freeresult($result); + + if (!empty($deactivated_style_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $this->config['default_style'] .' + WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); + $this->sql_query($sql); + } + } + + public function delete_orphan_private_messages() + { + // 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 = $this->db->sql_build_query('SELECT', $sql_array); + + $result = $this->db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $delete_pms[] = (int) $row['msg_id']; + } + $this->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); + + // Return false to have the Migrator call this function again + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php new file mode 100644 index 0000000000..fac8523e8c --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php @@ -0,0 +1,50 @@ +config['version'], '3.0.11-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11_rc1'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue', + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.11-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php new file mode 100644 index 0000000000..6a31a51201 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php @@ -0,0 +1,123 @@ +config['version'], '3.0.12-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), + + array('config.update', array('version', '3.0.12-rc1')), + ); + } + + public function disable_bots_from_receiving_pms() + { + // Disable receiving pms for bots + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $this->db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); + $this->sql_query($sql); + } + } + + public function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_u_sig\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'signature\''; + $this->sql_query($sql); + } + + public function update_bots() + { + // Update bots + if (!function_exists('user_delete')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $this->db->sql_query($sql); + $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php new file mode 100644 index 0000000000..562ccf077c --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php @@ -0,0 +1,108 @@ +config['version'], '3.0.1-rc1', '>='); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list' => array('BOOL', 1), + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'groups' => array( + 'group_legend', + ), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('session_forum_id'), + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list', + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + ), + 'add_index' => array( + $this->table_prefix . 'groups' => array( + 'group_legend' => array('group_legend'), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name', + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'fix_unset_last_view_time'))), + array('custom', array(array(&$this, 'reset_smiley_size'))), + + array('config.update', array('version', '3.0.1-rc1')), + ); + } + + public function fix_unset_last_view_time() + { + $sql = 'UPDATE ' . $this->table_prefix . "topics + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + $this->sql_query($sql); + } + + public function reset_smiley_size() + { + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; + + $this->sql_query($sql); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_2.php b/phpBB/includes/db/migration/data/30x/3_0_2.php new file mode 100644 index 0000000000..eed5acef82 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_2.php @@ -0,0 +1,28 @@ +config['version'], '3.0.2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_2_rc2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php new file mode 100644 index 0000000000..a960e90765 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php @@ -0,0 +1,32 @@ +config['version'], '3.0.2-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_1'); + } + + public function update_data() + { + return array( + array('config.add', array('referer_validation', '1')), + array('config.add', array('check_attachment_content', '1')), + array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), + + array('config.update', array('version', '3.0.2-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php new file mode 100644 index 0000000000..8917dfea77 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php @@ -0,0 +1,80 @@ +config['version'], '3.0.2-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_2_rc1'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'drafts' => array( + 'draft_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'posts' => array( + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'topics' => array( + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid' => array('session_forum_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array( + 'session_forum_id', + ), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid', + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.2-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_3.php b/phpBB/includes/db/migration/data/30x/3_0_3.php new file mode 100644 index 0000000000..8984cf7b76 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_3.php @@ -0,0 +1,28 @@ +config['version'], '3.0.3', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_3_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php new file mode 100644 index 0000000000..4b102e1a2e --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php @@ -0,0 +1,83 @@ +config['version'], '3.0.3-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_2'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients' => array('UINT', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id', + 'template_inherit_path', + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients', + ), + ), + ); + } + + public function update_data() + { + return array( + 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(array(&$this, 'set_group_default_max_recipients'))), + array('config.add', array('dbms_version', $this->db->sql_server_info(true))), + array('permission.add', array('u_masspm_group', true, 'u_masspm')), + array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + + array('config.update', array('version', '3.0.3-rc1')), + ); + } + + public 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); + } + + public function set_group_default_max_recipients() + { + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + 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/data/30x/3_0_4.php b/phpBB/includes/db/migration/data/30x/3_0_4.php new file mode 100644 index 0000000000..9a0c132e78 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_4.php @@ -0,0 +1,49 @@ +config['version'], '3.0.4', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_4_rc1'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'rename_log_delete_topic'))), + + array('config.update', array('version', '3.0.4')), + ); + } + + public function rename_log_delete_topic() + { + if ($this->db->sql_layer == 'oracle') + { + // log_operation is CLOB - but we can change this later + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + else + { + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php new file mode 100644 index 0000000000..8ad75a557b --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php @@ -0,0 +1,123 @@ +config['version'], '3.0.4-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_3'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile' => array('BOOL', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'styles' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_imageset' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_theme' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template_data' => array( + 'template_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_style' => array('UINT', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile', + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_custom_profile_fields'))), + + array('config.update', array('version', '3.0.4-rc1')), + ); + } + + public 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 = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + $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); + } + + $this->db->sql_freeresult($result); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_5.php b/phpBB/includes/db/migration/data/30x/3_0_5.php new file mode 100644 index 0000000000..16d2dee457 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_5.php @@ -0,0 +1,28 @@ +config['version'], '3.0.5', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_5_rc1part2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.5')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php new file mode 100644 index 0000000000..ea17cc1e31 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php @@ -0,0 +1,124 @@ +config['version'], '3.0.5-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_4'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + ), + ); + } + + public function update_data() + { + $search_indexing_state = $this->config['search_indexing_state']; + + 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_fonts', 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'))), + ); + } + + public function hash_old_passwords() + { + $sql = 'SELECT user_id, user_password + FROM ' . $this->table_prefix . 'users + WHERE user_pass_convert = 1'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); + } + } + $this->db->sql_freeresult($result); + } + + public function update_ichiro_bot() + { + // Adjust bot entry + $sql = 'UPDATE ' . $this->table_prefix . "bots + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + $this->sql_query($sql); + } + + public function remove_duplicate_auth_options() + { + // Before we are able to add a unique key to auth_option, we need to remove duplicate entries + $sql = 'SELECT auth_option + FROM ' . $this->table_prefix . 'acl_options + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $this->db->sql_query($sql); + + $auth_options = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $this->db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + 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 = $this->db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $this->db->sql_fetchrow($result); + + while ($row = $this->db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + $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']); + } + $this->db->sql_freeresult($result); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php new file mode 100644 index 0000000000..8538347b1a --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php @@ -0,0 +1,42 @@ +config['version'], '3.0.5-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_5_rc1'); + } + + public function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'acl_options' => array('auth_option'), + ), + 'add_unique_index' => array( + $this->table_prefix . 'acl_options' => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.5-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_6.php b/phpBB/includes/db/migration/data/30x/3_0_6.php new file mode 100644 index 0000000000..bb651dc7cd --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_6.php @@ -0,0 +1,28 @@ +config['version'], '3.0.6', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_6_rc4'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.6')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php new file mode 100644 index 0000000000..38c282ebf0 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php @@ -0,0 +1,324 @@ +config['version'], '3.0.6-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_5'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported' => array('BOOL', 0), + ), + $this->table_prefix . 'reports' => array( + 'pm_id' => array('UINT', 0), + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + $this->table_prefix . 'reports' => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + $this->table_prefix . 'posts' => array( + 'post_username' => array('post_username:255'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts', + ), + $this->table_prefix . 'users' => array( + 'user_new', + 'user_reminded', + 'user_reminded_time', + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth', + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported', + ), + $this->table_prefix . 'reports' => array( + 'pm_id', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt', + ), + $this->table_prefix . 'forums' => array( + 'forum_options', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'reports' => array( + 'post_id', + 'pm_id', + ), + $this->table_prefix . 'posts' => array( + 'post_username', + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), + array('if', array( + ($this->config['captcha_gd']), + array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), + )), + + array('config.add', array('feed_enable', 0)), + array('config.add', array('feed_limit', 10)), + array('config.add', array('feed_overall_forums', 1)), + array('config.add', array('feed_overall_forums_limit', 15)), + array('config.add', array('feed_overall_topics', 0)), + array('config.add', array('feed_overall_topics_limit', 15)), + array('config.add', array('feed_forum', 1)), + array('config.add', array('feed_topic', 1)), + array('config.add', array('feed_item_statistics', 1)), + + array('config.add', array('smilies_per_page', 50)), + array('config.add', array('allow_pm_report', 1)), + array('config.add', array('min_post_chars', 1)), + array('config.add', array('allow_quick_reply', 1)), + array('config.add', array('new_member_post_limit', 0)), + array('config.add', array('new_member_group_default', 0)), + array('config.add', array('delete_time', $this->config['edit_time'])), + + array('config.add', array('allow_avatar', 0)), + array('if', array( + ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), + array('config.update', array('allow_avatar', 1)), + )), + array('config.add', array('allow_avatar_remote_upload', 0)), + array('if', array( + ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), + array('config.update', array('allow_avatar_remote_upload', 1)), + )), + + array('module.add', array( + 'acp', + 'ACP_BOARD_CONFIGURATION', + array( + 'module_basename' => 'acp_board', + 'modes' => array('feed'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_CAT_USERS', + array( + 'module_basename' => 'acp_users', + 'modes' => array('warnings'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_SERVER_CONFIGURATION', + array( + 'module_basename' => 'acp_send_statistics', + 'modes' => array('send_statistics'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_FORUM_BASED_PERMISSIONS', + array( + 'module_basename' => 'acp_permissions', + 'modes' => array('setting_forum_copy'), + ), + )), + array('module.add', array( + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'mcp_pm_reports', + 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), + ), + )), + array('custom', array(array(&$this, 'add_newly_registered_group'))), + array('custom', array(array(&$this, 'set_user_options_default'))), + + array('config.update', array('version', '3.0.6-rc1')), + ); + } + + public function set_user_options_default() + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + $this->sql_query($sql); + } + + public function add_newly_registered_group() + { + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $this->db->sql_query($sql); + $group_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + $this->sql_query($sql); + + $group_id = $this->db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $u_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + $this->sql_query($sql); + $u_role = $this->db->sql_nextid(); + + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + $this->sql_query($sql); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + $this->sql_query($sql); + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $f_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + $this->sql_query($sql); + $f_role = $this->db->sql_nextid(); + + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + $this->sql_query($sql); + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + $this->sql_query($sql); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $this->db->sql_query($sql); + $is_options = (int) $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); + } + $this->db->sql_freeresult($result); + } + + // Clear permissions... + include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php new file mode 100644 index 0000000000..a939dbd489 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php @@ -0,0 +1,28 @@ +config['version'], '3.0.6-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_6_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.6-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php new file mode 100644 index 0000000000..b3f09d8ab8 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php @@ -0,0 +1,40 @@ +config['version'], '3.0.6-rc3', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_6_rc2'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_cp_fields'))), + + array('config.update', array('version', '3.0.6-rc3')), + ); + } + + public function update_cp_fields() + { + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' + SET field_show_on_vt = 1 + WHERE field_hide = 0 + AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php new file mode 100644 index 0000000000..fc2923f99b --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php @@ -0,0 +1,28 @@ +config['version'], '3.0.6-rc4', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_6_rc3'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.6-rc4')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_7.php b/phpBB/includes/db/migration/data/30x/3_0_7.php new file mode 100644 index 0000000000..9ff2e9e4ab --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_7.php @@ -0,0 +1,28 @@ +config['version'], '3.0.7', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_7_rc2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.7')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php b/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php new file mode 100644 index 0000000000..c9cc9d19ac --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php @@ -0,0 +1,28 @@ +config['version'], '3.0.7-pl1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_7'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.7-pl1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php new file mode 100644 index 0000000000..ffebf66f2d --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php @@ -0,0 +1,76 @@ +config['version'], '3.0.7-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_6'); + } + + public function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'log' => array( + 'log_time', + ), + ), + 'add_index' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id' => array('topic_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'log' => array( + 'log_time' => array('log_time'), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id', + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.add', array('feed_overall', 1)), + array('config.add', array('feed_http_auth', 0)), + array('config.add', array('feed_limit_post', $this->config['feed_limit'])), + array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), + array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), + array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), + array('custom', array(array(&$this, 'delete_text_templates'))), + + array('config.update', array('version', '3.0.7-rc1')), + ); + } + + public function delete_text_templates() + { + // Delete all text-templates from the template_data + $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' + WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php new file mode 100644 index 0000000000..55bc2bc679 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php @@ -0,0 +1,73 @@ +config['version'], '3.0.7-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_7_rc1'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_email_hash'))), + + array('config.update', array('version', '3.0.7-rc2')), + ); + } + + public function update_email_hash($start = 0) + { + $limit = 1000; + + $sql = 'SELECT user_id, user_email, user_email_hash + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $this->db->sql_query_limit($sql, $limit, $start); + + $i = 0; + while ($row = $this->db->sql_fetchrow($result)) + { + $i++; + + // Snapshot of the phpbb_email_hash() function + // We cannot call it directly because the auto updater updates the DB first. :/ + $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); + + if ($user_email_hash != $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + $this->sql_query($sql); + } + } + $this->db->sql_freeresult($result); + + if ($i < $limit) + { + // Completed + return; + } + + // Return the next start, will be sent to $start when this function is called again + return $start + $limit; + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_8.php b/phpBB/includes/db/migration/data/30x/3_0_8.php new file mode 100644 index 0000000000..8998ef9627 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_8.php @@ -0,0 +1,28 @@ +config['version'], '3.0.8', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_8_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.8')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php new file mode 100644 index 0000000000..aeff35333e --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php @@ -0,0 +1,221 @@ +config['version'], '3.0.8-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_7_pl1'); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), + array('module.add', array( + 'acp', + 'ACP_MESSAGES', + array( + 'module_basename' => 'acp_board', + 'modes' => array('post'), + ), + )), + array('config.add', array('load_unreads_search', 1)), + array('config.update_if_equals', array(600, 'queue_interval', 60)), + array('config.update_if_equals', array(50, 'email_package_size', 20)), + + array('config.update', array('version', '3.0.8-rc1')), + ); + } + + public function update_file_extension_group_names() + { + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; + $this->sql_query($sql); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $this->db->sql_freeresult($result); + } + + public function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + $this->sql_query($sql); + } + + public function update_bots() + { + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; + $result = $this->db->sql_query($sql); + $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $this->db->sql_query($sql); + $group_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $this->config['default_lang'], + 'user_style' => $this->config['default_style'], + 'user_timezone' => 0, + 'user_dateformat' => $this->config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + $this->sql_query($sql); + } + } + + public function delete_orphan_shadow_topics() + { + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); + $this->db->sql_query($sql); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_9.php b/phpBB/includes/db/migration/data/30x/3_0_9.php new file mode 100644 index 0000000000..d5269ea6f0 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_9.php @@ -0,0 +1,28 @@ +config['version'], '3.0.9', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_9_rc4'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.9')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php new file mode 100644 index 0000000000..1f8622798e --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php @@ -0,0 +1,124 @@ +config['version'], '3.0.9-rc1', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_8'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'login_attempts' => array( + 'COLUMNS' => array( + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.12 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + //'PRIMARY_KEY' => 'attempt_id', + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'bbcodes' => array( + 'bbcode_id' => array('USINT', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'login_attempts', + ), + ); + } + + public function update_data() + { + 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'))), + + array('config.update', array('version', '3.0.9-rc1')), + ); + } + + public 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 ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); + $result = $this->db->sql_query($sql); + + 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 ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE group_id = ' . $row['group_id']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + public 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 ($this->db_tools->sql_layer == 'firebird') + { + $tables = array( + $this->table_prefix . 'captcha_questions', + $this->table_prefix . 'captcha_answers', + $this->table_prefix . 'qa_confirm', + ); + foreach ($tables as $table) + { + if ($this->db_tools->sql_table_exists($table)) + { + $this->db_tools->sql_table_drop($table); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php new file mode 100644 index 0000000000..c0e662aa45 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php @@ -0,0 +1,28 @@ +config['version'], '3.0.9-rc2', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_9_rc1'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php new file mode 100644 index 0000000000..d6d1f14b2e --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php @@ -0,0 +1,28 @@ +config['version'], '3.0.9-rc3', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_9_rc2'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php new file mode 100644 index 0000000000..e673249343 --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php @@ -0,0 +1,28 @@ +config['version'], '3.0.9-rc4', '>='); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_9_rc3'); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc4')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php new file mode 100644 index 0000000000..f41750e327 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -0,0 +1,406 @@ +config['version'], '3.1.0-dev', '>='); + } + + static public function depends_on() + { + return array( + 'phpbb_db_migration_data_30x_11', + 'phpbb_db_migration_data_310_extensions', + 'phpbb_db_migration_data_310_style_update_p2', + 'phpbb_db_migration_data_310_timezone_p2', + 'phpbb_db_migration_data_310_reported_posts_display', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'groups' => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_pm' => array('BOOL', 0), + ), + $this->table_prefix . 'styles' => array( + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + $this->table_prefix . 'reports' => array( + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'groups' => array( + 'group_legend' => array('UINT', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'groups' => array( + 'group_teampage', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_pm', + ), + $this->table_prefix . 'styles' => array( + 'style_path', + 'bbcode_bitfield', + 'style_parent_id', + 'style_parent_tree', + ), + $this->table_prefix . 'reports' => array( + 'reported_post_text', + 'reported_post_uid', + 'reported_post_bitfield', + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + + array('config.add', array('fulltext_postgres_ts_name', 'simple')), + array('config.add', array('fulltext_postgres_min_word_len', 4)), + array('config.add', array('fulltext_postgres_max_word_len', 254)), + array('config.add', array('fulltext_sphinx_stopwords', 0)), + array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), + + array('config.add', array('load_jquery_cdn', 0)), + array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), + + array('config.add', array('use_system_cron', 0)), + + array('config.add', array('legend_sort_groupname', 0)), + array('config.add', array('teampage_forums', 1)), + array('config.add', array('teampage_memberships', 1)), + + array('config.add', array('load_cpf_pm', 0)), + + array('config.add', array('display_last_subject', 1)), + + array('config.add', array('assets_version', 1)), + + array('config.add', array('site_home_url', '')), + array('config.add', array('site_home_text', '')), + + array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), + + array('module.add', array( + 'acp', + 'ACP_GROUPS', + array( + 'module_basename' => 'acp_groups', + 'modes' => array('position'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_ATTACHMENTS', + array( + 'module_basename' => 'acp_attachments', + 'modes' => array('manage'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_STYLE_MANAGEMENT', + array( + 'module_basename' => 'acp_styles', + 'modes' => array('install', 'cache'), + ), + )), + array('module.add', array( + 'ucp', + 'UCP_PROFILE', + array( + 'module_basename' => 'ucp_profile', + 'modes' => array('autologin_keys'), + ), + )), + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_LANGUAGE' + )), + + array('module.remove', array( + 'acp', + false, + 'ACP_TEMPLATES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_THEMES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_IMAGESETS', + )), + + array('custom', array(array($this, 'rename_module_basenames'))), + array('custom', array(array($this, 'rename_styles_module'))), + array('custom', array(array($this, 'add_group_teampage'))), + array('custom', array(array($this, 'update_group_legend'))), + array('custom', array(array($this, 'localise_global_announcements'))), + array('custom', array(array($this, 'update_ucp_pm_basename'))), + array('custom', array(array($this, 'update_ucp_profile_auth'))), + array('custom', array(array($this, 'move_customise_modules'))), + + array('config.update', array('version', '3.1.0-dev')), + ); + } + + public function move_customise_modules() + { + // Move language management to new location in the Customise tab + // First get language module id + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_language'"; + $result = $this->db->sql_query($sql); + $language_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $this->db->sql_query($sql); + $language_management_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); + } + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); + } + + public function update_ucp_pm_basename() + { + $sql = 'SELECT module_id, module_basename + FROM ' . MODULES_TABLE . " + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM'"; + $result = $this->db->sql_query_limit($sql, 1); + + if ($row = $this->db->sql_fetchrow($result)) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; + + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + public function update_ucp_profile_auth() + { + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'profile_info'"; + $this->sql_query($sql); + } + + public function rename_styles_module() + { + // Rename styles module to Customise + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + $this->sql_query($sql); + } + + public function rename_module_basenames() + { + // rename all module basenames to full classname + $sql = 'SELECT module_id, module_basename, module_class + FROM ' . MODULES_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $module_id = (int) $row['module_id']; + unset($row['module_id']); + + if (!empty($row['module_basename']) && !empty($row['module_class'])) + { + // all the class names start with class name or with phpbb_ for auto loading + if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && + strpos($row['module_basename'], 'phpbb_') !== 0) + { + $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; + + $sql_update = $this->db->sql_build_array('UPDATE', $row); + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $sql_update . ' + WHERE module_id = ' . $module_id; + $this->sql_query($sql); + } + } + } + + $this->db->sql_freeresult($result); + } + + public function add_group_teampage() + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + $this->sql_query($sql); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + $this->sql_query($sql); + } + + public function update_group_legend() + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $this->db->sql_query($sql); + + $next_legend = 1; + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + $this->sql_query($sql); + + $next_legend++; + } + $this->db->sql_freeresult($result); + } + + public function localise_global_announcements() + { + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $this->db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $this->db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $this->db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST; + $result = $this->db->sql_query_limit($sql, 1); + $ga_forum_id = $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $this->db->sql_query($sql); + $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); + $this->db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + $this->sql_query($sql); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); + $this->sql_query($sql); + } + unset($table_ary); + } + } +} diff --git a/phpBB/includes/db/migration/data/310/extensions.php b/phpBB/includes/db/migration/data/310/extensions.php new file mode 100644 index 0000000000..925fa29384 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/extensions.php @@ -0,0 +1,69 @@ +db_tools->sql_table_exists($this->table_prefix . 'ext'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_11'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'ext' => array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'ext', + ), + ); + } + + public function update_data() + { + return array( + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_EXTENSION_MANAGEMENT' + )), + array('module.add', array( + 'acp', + 'ACP_EXTENSION_MANAGEMENT', + array( + 'module_basename' => 'acp_extensions', + 'modes' => array('main'), + ), + )), + array('permission.add', array('a_extensions', true, 'a_styles')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/310/reported_posts_display.php b/phpBB/includes/db/migration/data/310/reported_posts_display.php new file mode 100644 index 0000000000..64f0f1aaec --- /dev/null +++ b/phpBB/includes/db/migration/data/310/reported_posts_display.php @@ -0,0 +1,42 @@ +db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode', + 'reported_post_enable_smilies', + 'reported_post_enable_magic_url', + ), + ), + ); + } +} diff --git a/phpBB/includes/db/migration/data/310/style_update_p1.php b/phpBB/includes/db/migration/data/310/style_update_p1.php new file mode 100644 index 0000000000..d19ccc37cf --- /dev/null +++ b/phpBB/includes/db/migration/data/310/style_update_p1.php @@ -0,0 +1,157 @@ +db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_11'); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'styles_update'))), + ); + } + + public function styles_update() + { + // Get list of valid 3.1 styles + $available_styles = array('prosilver'); + + $iterator = new DirectoryIterator($this->phpbb_root_path . 'styles'); + $skip_dirs = array('.', '..', 'prosilver'); + foreach ($iterator as $fileinfo) + { + if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) + { + $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); + if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) + { + // 3.1 style + $available_styles[] = $fileinfo->getFilename(); + } + } + } + + // Get all installed styles + if ($this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset')) + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . 'styles_theme c, ' . $this->table_prefix . "styles_imageset i + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id + AND i.imageset_id = s.imageset_id"; + } + else + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id"; + } + $result = $this->db->sql_query($sql); + + $styles = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $styles[] = $row; + } + $this->db->sql_freeresult($result); + + // Decide which styles to keep, all others will be deleted + $valid_styles = array(); + foreach ($styles as $style_row) + { + if ( + // Delete styles with parent style (not supported yet) + $style_row['template_inherits_id'] == 0 && + // Check if components match + $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && + // Check if components are valid + in_array($style_row['template_path'], $available_styles) + ) + { + // Valid style. Keep it + $sql_ary = array( + 'style_path' => $style_row['template_path'], + 'bbcode_bitfield' => $style_row['bbcode_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + ); + $this->sql_query('UPDATE ' . STYLES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE style_id = ' . $style_row['style_id']); + $valid_styles[] = (int) $style_row['style_id']; + } + } + + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql_ary = array( + 'style_name' => 'prosilver', + 'style_copyright' => '© phpBB Group', + 'style_active' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'lNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', + + // Will be removed in the next step + 'imageset_id' => 0, + 'template_id' => 0, + 'theme_id' => 0, + ); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->sql_query($sql); + + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = $this->sql_query($sql); + $default_style = $this->db->sql_fetchfield($result); + $this->db->sql_freeresult($result); + + set_config('default_style', $default_style); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $this->sql_query($sql); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' + WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); + + // Change default style + if (!in_array($this->config['default_style'], $valid_styles)) + { + $this->sql_query('UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $valid_styles[0] . "' + WHERE config_name = 'default_style'"); + } + + // Reset styles for users + $this->sql_query('UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); + } + } +} diff --git a/phpBB/includes/db/migration/data/310/style_update_p2.php b/phpBB/includes/db/migration/data/310/style_update_p2.php new file mode 100644 index 0000000000..7b10518a66 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/style_update_p2.php @@ -0,0 +1,129 @@ +db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_310_style_update_p1'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + + 'drop_tables' => array( + $this->table_prefix . 'styles_imageset', + $this->table_prefix . 'styles_imageset_data', + $this->table_prefix . 'styles_template', + $this->table_prefix . 'styles_template_data', + $this->table_prefix . 'styles_theme', + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id' => array('UINT', 0), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + ), + ), + + 'add_tables' => array( + $this->table_prefix . 'styles_imageset' => array( + 'COLUMNS' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_name' => array('VCHAR_UNI:255', ''), + 'imageset_copyright' => array('VCHAR_UNI', ''), + 'imageset_path' => array('VCHAR:100', ''), + ), + 'PRIMARY_KEY' => 'imageset_id', + 'KEYS' => array( + 'imgset_nm' => array('UNIQUE', 'imageset_name'), + ), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'COLUMNS' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'image_name' => array('VCHAR:200', ''), + 'image_filename' => array('VCHAR:200', ''), + 'image_lang' => array('VCHAR:30', ''), + 'image_height' => array('USINT', 0), + 'image_width' => array('USINT', 0), + 'imageset_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'image_id', + 'KEYS' => array( + 'i_d' => array('INDEX', 'imageset_id'), + ), + ), + $this->table_prefix . 'styles_template' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + 'template_name' => array('VCHAR_UNI:255', ''), + 'template_copyright' => array('VCHAR_UNI', ''), + 'template_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'template_storedb' => array('BOOL', 0), + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'template_id', + 'KEYS' => array( + 'tmplte_nm' => array('UNIQUE', 'template_name'), + ), + ), + $this->table_prefix . 'styles_template_data' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', 0), + 'template_filename' => array('VCHAR:100', ''), + 'template_included' => array('TEXT', ''), + 'template_mtime' => array('TIMESTAMP', 0), + 'template_data' => array('MTEXT_UNI', ''), + ), + 'KEYS' => array( + 'tid' => array('INDEX', 'template_id'), + 'tfn' => array('INDEX', 'template_filename'), + ), + ), + $this->table_prefix . 'styles_theme' => array( + 'COLUMNS' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + 'theme_name' => array('VCHAR_UNI:255', ''), + 'theme_copyright' => array('VCHAR_UNI', ''), + 'theme_path' => array('VCHAR:100', ''), + 'theme_storedb' => array('BOOL', 0), + 'theme_mtime' => array('TIMESTAMP', 0), + 'theme_data' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'theme_id', + 'KEYS' => array( + 'theme_name' => array('UNIQUE', 'theme_name'), + ), + ), + ), + ); + } +} diff --git a/phpBB/includes/db/migration/data/310/timezone.php b/phpBB/includes/db/migration/data/310/timezone.php new file mode 100644 index 0000000000..7a6a9bce05 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/timezone.php @@ -0,0 +1,163 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_11'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_timezone' => array('VCHAR:100', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_timezones'))), + ); + } + + public function update_timezones() + { + // Update user timezones + $sql = 'SELECT user_dst, user_timezone + FROM ' . $this->table_prefix . 'users + GROUP BY user_timezone, user_dst'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' + AND user_dst = " . (int) $row['user_dst']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + + // Update board default timezone + $sql = 'UPDATE ' . $this->table_prefix . "config + SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' + WHERE config_name = 'board_timezone'"; + $this->sql_query($sql); + } + + /** + * Determine the new timezone for a given phpBB 3.0 timezone and + * "Daylight Saving Time" option + * + * @param $timezone float Users timezone in 3.0 + * @param $dst int Users daylight saving time + * @return string Users new php Timezone which is used since 3.1 + */ + public function convert_phpbb30_timezone($timezone, $dst) + { + $offset = $timezone + $dst; + + switch ($timezone) + { + case '-12': + return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time' + case '-11': + return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time' + case '-10': + return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' + case '-9.5': + return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' + case '-9': + return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time' + case '-8': + return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time' + case '-7': + return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time' + case '-6': + return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time' + case '-5': + return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time' + case '-4.5': + return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' + case '-4': + return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time' + case '-3.5': + return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' + case '-3': + return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time' + case '-2': + return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' + case '-1': + return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' + case '0': + return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time' + case '1': + return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time' + case '2': + return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' + case '3': + return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' + case '3.5': + return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' + case '4': + return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' + case '4.5': + return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' + case '5': + return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' + case '5.5': + return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' + case '5.75': + return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' + case '6': + return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' + case '6.5': + return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' + case '7': + return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' + case '8': + return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' + case '8.75': + return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' + case '9': + return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' + case '9.5': + return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' + case '10': + return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' + case '10.5': + return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' + case '11': + return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' + case '11.5': + return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' + case '12': + return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' + case '12.75': + return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' + case '13': + return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' + case '14': + return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' + default: + return 'UTC'; + } + } +} diff --git a/phpBB/includes/db/migration/data/310/timezone_p2.php b/phpBB/includes/db/migration/data/310/timezone_p2.php new file mode 100644 index 0000000000..113b979e4f --- /dev/null +++ b/phpBB/includes/db/migration/data/310/timezone_p2.php @@ -0,0 +1,43 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_310_timezone'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst' => array('BOOL', 0), + ), + ), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php deleted file mode 100644 index 8b7c6f0f7c..0000000000 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_1_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php deleted file mode 100644 index b24a876bac..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.10', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc3'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.10')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php deleted file mode 100644 index 46b7db4e59..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ /dev/null @@ -1,30 +0,0 @@ -config['version'], '3.0.10-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_9'); - } - - public function update_data() - { - return array( - array('config.add', array('email_max_chunk_size', 50)), - - array('config.update', array('version', '3.0.10-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php deleted file mode 100644 index 5e85467202..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.10-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.10-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php deleted file mode 100644 index 6ff81f7776..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.10-rc3', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.10-rc3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php deleted file mode 100644 index 1a63508593..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.11', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11_rc2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.11')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php deleted file mode 100644 index 19703bcc35..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ /dev/null @@ -1,95 +0,0 @@ -config['version'], '3.0.11-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_10'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), - array('custom', array(array(&$this, 'delete_orphan_private_messages'))), - - array('config.update', array('version', '3.0.11-rc1')), - ); - } - - public function cleanup_deactivated_styles() - { - // Updates users having current style a deactivated one - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_active = 0'; - $result = $this->sql_query($sql); - - $deactivated_style_ids = array(); - while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) - { - $deactivated_style_ids[] = (int) $style_id; - } - $this->db->sql_freeresult($result); - - if (!empty($deactivated_style_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->config['default_style'] .' - WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); - $this->sql_query($sql); - } - } - - public function delete_orphan_private_messages() - { - // 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 = $this->db->sql_build_query('SELECT', $sql_array); - - $result = $this->db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $this->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); - - // Return false to have the Migrator call this function again - return false; - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php deleted file mode 100644 index 219d44c4e0..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ /dev/null @@ -1,50 +0,0 @@ -config['version'], '3.0.11-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11_rc1'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_novalue' => array('BOOL', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_novalue', - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.11-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php deleted file mode 100644 index c23e8b24b8..0000000000 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ /dev/null @@ -1,123 +0,0 @@ -config['version'], '3.0.12-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_module_auth'))), - array('custom', array(array(&$this, 'update_bots'))), - array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), - - array('config.update', array('version', '3.0.12-rc1')), - ); - } - - public function disable_bots_from_receiving_pms() - { - // Disable receiving pms for bots - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $this->db->sql_query($sql); - - $bot_user_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $bot_user_ids[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - if (!empty($bot_user_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); - $this->sql_query($sql); - } - } - - public function update_module_auth() - { - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_u_sig\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'signature\''; - $this->sql_query($sql); - } - - public function update_bots() - { - // Update bots - if (!function_exists('user_delete')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $bots_updates = array( - // Bot Deletions - 'NG-Search [Bot]' => false, - 'Nutch/CVS [Bot]' => false, - 'OmniExplorer [Bot]' => false, - 'Seekport [Bot]' => false, - 'Synoo [Bot]' => false, - 'WiseNut [Bot]' => false, - - // Bot Updates - // Bot name to bot user agent map - 'Baidu [Spider]' => 'Baiduspider', - 'Exabot [Bot]' => 'Exabot', - 'Voyager [Bot]' => 'voyager/', - 'W3C [Validator]' => 'W3C_Validator', - ); - - foreach ($bots_updates as $bot_name => $bot_agent) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_IGNORE . " - AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; - $result = $this->db->sql_query($sql); - $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); - $this->db->sql_freeresult($result); - - if ($bot_user_id) - { - if ($bot_agent === false) - { - $sql = 'DELETE FROM ' . BOTS_TABLE . " - WHERE user_id = $bot_user_id"; - $this->sql_query($sql); - - user_delete('remove', $bot_user_id); - } - else - { - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' - WHERE user_id = $bot_user_id"; - $this->sql_query($sql); - } - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php deleted file mode 100644 index 2fc2849d04..0000000000 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ /dev/null @@ -1,108 +0,0 @@ -config['version'], '3.0.1-rc1', '>='); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'forums' => array( - 'display_subforum_list' => array('BOOL', 1), - ), - $this->table_prefix . 'sessions' => array( - 'session_forum_id' => array('UINT', 0), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'groups' => array( - 'group_legend', - ), - ), - 'add_index' => array( - $this->table_prefix . 'sessions' => array( - 'session_forum_id' => array('session_forum_id'), - ), - $this->table_prefix . 'groups' => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'forums' => array( - 'display_subforum_list', - ), - $this->table_prefix . 'sessions' => array( - 'session_forum_id', - ), - ), - 'add_index' => array( - $this->table_prefix . 'groups' => array( - 'group_legend' => array('group_legend'), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'sessions' => array( - 'session_forum_id', - ), - $this->table_prefix . 'groups' => array( - 'group_legend_name', - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'fix_unset_last_view_time'))), - array('custom', array(array(&$this, 'reset_smiley_size'))), - - array('config.update', array('version', '3.0.1-rc1')), - ); - } - - public function fix_unset_last_view_time() - { - $sql = 'UPDATE ' . $this->table_prefix . "topics - SET topic_last_view_time = topic_last_post_time - WHERE topic_last_view_time = 0"; - $this->sql_query($sql); - } - - public function reset_smiley_size() - { - // Update smiley sizes - $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); - - foreach ($smileys as $smiley) - { - if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) - { - list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET smiley_width = ' . $width . ', smiley_height = ' . $height . " - WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; - - $this->sql_query($sql); - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php deleted file mode 100644 index 8aa975f779..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_2_rc2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php deleted file mode 100644 index 6081cd682c..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ /dev/null @@ -1,32 +0,0 @@ -config['version'], '3.0.2-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_1'); - } - - public function update_data() - { - return array( - array('config.add', array('referer_validation', '1')), - array('config.add', array('check_attachment_content', '1')), - array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), - - array('config.update', array('version', '3.0.2-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php deleted file mode 100644 index bb76c270d7..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ /dev/null @@ -1,80 +0,0 @@ -config['version'], '3.0.2-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_2_rc1'); - } - - public function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'drafts' => array( - 'draft_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'forums' => array( - 'forum_last_post_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'posts' => array( - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - ), - $this->table_prefix . 'privmsgs' => array( - 'message_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'topics' => array( - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'sessions' => array( - 'session_forum_id', - ), - ), - 'add_index' => array( - $this->table_prefix . 'sessions' => array( - 'session_fid' => array('session_forum_id'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'add_index' => array( - $this->table_prefix . 'sessions' => array( - 'session_forum_id' => array( - 'session_forum_id', - ), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'sessions' => array( - 'session_fid', - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.2-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php deleted file mode 100644 index 82039a109b..0000000000 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.3', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_3_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php deleted file mode 100644 index 5e300962b7..0000000000 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ /dev/null @@ -1,83 +0,0 @@ -config['version'], '3.0.3-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_2'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'styles_template' => array( - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - $this->table_prefix . 'groups' => array( - 'group_max_recipients' => array('UINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'styles_template' => array( - 'template_inherits_id', - 'template_inherit_path', - ), - $this->table_prefix . 'groups' => array( - 'group_max_recipients', - ), - ), - ); - } - - public function update_data() - { - return array( - 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(array(&$this, 'set_group_default_max_recipients'))), - array('config.add', array('dbms_version', $this->db->sql_server_info(true))), - array('permission.add', array('u_masspm_group', true, 'u_masspm')), - array('custom', array(array(&$this, 'correct_acp_email_permissions'))), - - array('config.update', array('version', '3.0.3-rc1')), - ); - } - - public 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); - } - - public function set_group_default_max_recipients() - { - // Set maximum number of recipients for the registered users, bots, guests group - $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 - 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/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php deleted file mode 100644 index 34af9fa4ae..0000000000 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ /dev/null @@ -1,49 +0,0 @@ -config['version'], '3.0.4', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_4_rc1'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'rename_log_delete_topic'))), - - array('config.update', array('version', '3.0.4')), - ); - } - - public function rename_log_delete_topic() - { - if ($this->db->sql_layer == 'oracle') - { - // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . $this->table_prefix . "log - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - $this->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . $this->table_prefix . "log - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - $this->sql_query($sql); - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php deleted file mode 100644 index f63bebcf75..0000000000 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ /dev/null @@ -1,123 +0,0 @@ -config['version'], '3.0.4-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_3'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'styles' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_imageset' => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_imageset_data' => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_theme' => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template' => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template_data' => array( - 'template_id' => array('UINT', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_style' => array('UINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile', - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_custom_profile_fields'))), - - array('config.update', array('version', '3.0.4-rc1')), - ); - } - - public 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 = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - $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); - } - - $this->db->sql_freeresult($result); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php deleted file mode 100644 index 077ed251d2..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.5', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_5_rc1part2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.5')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php deleted file mode 100644 index df85ee4f7d..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ /dev/null @@ -1,124 +0,0 @@ -config['version'], '3.0.5-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_4'); - } - - public function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - ), - ); - } - - public function update_data() - { - $search_indexing_state = $this->config['search_indexing_state']; - - 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_fonts', 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'))), - ); - } - - public function hash_old_passwords() - { - $sql = 'SELECT user_id, user_password - FROM ' . $this->table_prefix . 'users - WHERE user_pass_convert = 1'; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if (strlen($row['user_password']) == 32) - { - $sql_ary = array( - 'user_password' => phpbb_hash($row['user_password']), - ); - - $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); - } - } - $this->db->sql_freeresult($result); - } - - public function update_ichiro_bot() - { - // Adjust bot entry - $sql = 'UPDATE ' . $this->table_prefix . "bots - SET bot_agent = 'ichiro/' - WHERE bot_agent = 'ichiro/2'"; - $this->sql_query($sql); - } - - public function remove_duplicate_auth_options() - { - // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - $sql = 'SELECT auth_option - FROM ' . $this->table_prefix . 'acl_options - GROUP BY auth_option - HAVING COUNT(*) >= 2'; - $result = $this->db->sql_query($sql); - - $auth_options = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $auth_options[] = $row['auth_option']; - } - $this->db->sql_freeresult($result); - - // Remove specific auth options - if (!empty($auth_options)) - { - foreach ($auth_options as $option) - { - // Select auth_option_ids... the largest id will be preserved - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - 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 = $this->db->sql_query($sql); - - // Skip first row, this is our original auth option we want to preserve - $row = $this->db->sql_fetchrow($result); - - while ($row = $this->db->sql_fetchrow($result)) - { - // Ok, remove this auth option... - $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']); - } - $this->db->sql_freeresult($result); - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php deleted file mode 100644 index d2fad7a7f8..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ /dev/null @@ -1,42 +0,0 @@ -config['version'], '3.0.5-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_5_rc1'); - } - - public function update_schema() - { - return array( - 'drop_keys' => array( - $this->table_prefix . 'acl_options' => array('auth_option'), - ), - 'add_unique_index' => array( - $this->table_prefix . 'acl_options' => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.5-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php deleted file mode 100644 index 1b0cbb1435..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.6', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc4'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.6')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php deleted file mode 100644 index 0f85084e65..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ /dev/null @@ -1,324 +0,0 @@ -config['version'], '3.0.6-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_5'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'confirm' => array( - 'attempts' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time' => array('TIMESTAMP', 0), - ), - $this->table_prefix . 'groups' => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - $this->table_prefix . 'privmsgs' => array( - 'message_reported' => array('BOOL', 0), - ), - $this->table_prefix . 'reports' => array( - 'pm_id' => array('UINT', 0), - ), - $this->table_prefix . 'profile_fields' => array( - 'field_show_on_vt' => array('BOOL', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_options' => array('UINT:20', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'users' => array( - 'user_options' => array('UINT:11', 230271), - ), - ), - 'add_index' => array( - $this->table_prefix . 'reports' => array( - 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), - ), - $this->table_prefix . 'posts' => array( - 'post_username' => array('post_username:255'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'confirm' => array( - 'attempts', - ), - $this->table_prefix . 'users' => array( - 'user_new', - 'user_reminded', - 'user_reminded_time', - ), - $this->table_prefix . 'groups' => array( - 'group_skip_auth', - ), - $this->table_prefix . 'privmsgs' => array( - 'message_reported', - ), - $this->table_prefix . 'reports' => array( - 'pm_id', - ), - $this->table_prefix . 'profile_fields' => array( - 'field_show_on_vt', - ), - $this->table_prefix . 'forums' => array( - 'forum_options', - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'reports' => array( - 'post_id', - 'pm_id', - ), - $this->table_prefix . 'posts' => array( - 'post_username', - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), - array('if', array( - ($this->config['captcha_gd']), - array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), - )), - - array('config.add', array('feed_enable', 0)), - array('config.add', array('feed_limit', 10)), - array('config.add', array('feed_overall_forums', 1)), - array('config.add', array('feed_overall_forums_limit', 15)), - array('config.add', array('feed_overall_topics', 0)), - array('config.add', array('feed_overall_topics_limit', 15)), - array('config.add', array('feed_forum', 1)), - array('config.add', array('feed_topic', 1)), - array('config.add', array('feed_item_statistics', 1)), - - array('config.add', array('smilies_per_page', 50)), - array('config.add', array('allow_pm_report', 1)), - array('config.add', array('min_post_chars', 1)), - array('config.add', array('allow_quick_reply', 1)), - array('config.add', array('new_member_post_limit', 0)), - array('config.add', array('new_member_group_default', 0)), - array('config.add', array('delete_time', $this->config['edit_time'])), - - array('config.add', array('allow_avatar', 0)), - array('if', array( - ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), - array('config.update', array('allow_avatar', 1)), - )), - array('config.add', array('allow_avatar_remote_upload', 0)), - array('if', array( - ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), - array('config.update', array('allow_avatar_remote_upload', 1)), - )), - - array('module.add', array( - 'acp', - 'ACP_BOARD_CONFIGURATION', - array( - 'module_basename' => 'acp_board', - 'modes' => array('feed'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_CAT_USERS', - array( - 'module_basename' => 'acp_users', - 'modes' => array('warnings'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_SERVER_CONFIGURATION', - array( - 'module_basename' => 'acp_send_statistics', - 'modes' => array('send_statistics'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_FORUM_BASED_PERMISSIONS', - array( - 'module_basename' => 'acp_permissions', - 'modes' => array('setting_forum_copy'), - ), - )), - array('module.add', array( - 'mcp', - 'MCP_REPORTS', - array( - 'module_basename' => 'mcp_pm_reports', - 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), - ), - )), - array('custom', array(array(&$this, 'add_newly_registered_group'))), - array('custom', array(array(&$this, 'set_user_options_default'))), - - array('config.update', array('version', '3.0.6-rc1')), - ); - } - - public function set_user_options_default() - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - $this->sql_query($sql); - } - - public function add_newly_registered_group() - { - // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $this->db->sql_query($sql); - $group_id = (int) $this->db->sql_fetchfield('group_id'); - $this->db->sql_freeresult($result); - - if (!$group_id) - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - $this->sql_query($sql); - - $group_id = $this->db->sql_nextid(); - } - - // Insert new user role... at the end of the chain - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_USER_NEW_MEMBER' - AND role_type = 'u_'"; - $result = $this->db->sql_query($sql); - $u_role = (int) $this->db->sql_fetchfield('role_id'); - $this->db->sql_freeresult($result); - - if (!$u_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'u_'"; - $result = $this->db->sql_query($sql); - $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); - $this->db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - $this->sql_query($sql); - $u_role = $this->db->sql_nextid(); - - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - $this->sql_query($sql); - - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - $this->sql_query($sql); - } - - // Insert new forum role - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' - AND role_type = 'f_'"; - $result = $this->db->sql_query($sql); - $f_role = (int) $this->db->sql_fetchfield('role_id'); - $this->db->sql_freeresult($result); - - if (!$f_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'f_'"; - $result = $this->db->sql_query($sql); - $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); - $this->db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - $this->sql_query($sql); - $f_role = $this->db->sql_nextid(); - - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - $this->sql_query($sql); - } - - // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) - $sql = 'SELECT 1 - FROM ' . USERS_TABLE . ' - WHERE user_new = 0'; - $result = $this->db->sql_query_limit($sql, 1); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - $this->sql_query($sql); - } - - // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... - // Check if the role is already assigned... - $sql = 'SELECT forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id = ' . $f_role; - $result = $this->db->sql_query($sql); - $is_options = (int) $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - // Not assigned at all... :/ - if (!$is_options) - { - // Get postable forums - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type != ' . FORUM_LINK; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); - } - $this->db->sql_freeresult($result); - } - - // Clear permissions... - include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); - $auth_admin = new auth_admin(); - $auth_admin->acl_clear_prefetch(); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php deleted file mode 100644 index a9c497b3cd..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.6-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.6-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php deleted file mode 100644 index eca19fc2ff..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ /dev/null @@ -1,40 +0,0 @@ -config['version'], '3.0.6-rc3', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc2'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_cp_fields'))), - - array('config.update', array('version', '3.0.6-rc3')), - ); - } - - public function update_cp_fields() - { - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' - SET field_show_on_vt = 1 - WHERE field_hide = 0 - AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - $this->sql_query($sql); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php deleted file mode 100644 index 19611d3c56..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.6-rc4', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc3'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.6-rc4')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php deleted file mode 100644 index 97cdf4e3f1..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.7', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_rc2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.7')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php deleted file mode 100644 index 176854a8a6..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.7-pl1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_7'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.7-pl1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php deleted file mode 100644 index daf52213b9..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ /dev/null @@ -1,76 +0,0 @@ -config['version'], '3.0.7-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_6'); - } - - public function update_schema() - { - return array( - 'drop_keys' => array( - $this->table_prefix . 'log' => array( - 'log_time', - ), - ), - 'add_index' => array( - $this->table_prefix . 'topics_track' => array( - 'topic_id' => array('topic_id'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'add_index' => array( - $this->table_prefix . 'log' => array( - 'log_time' => array('log_time'), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'topics_track' => array( - 'topic_id', - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.add', array('feed_overall', 1)), - array('config.add', array('feed_http_auth', 0)), - array('config.add', array('feed_limit_post', $this->config['feed_limit'])), - array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), - array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), - array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), - array('custom', array(array(&$this, 'delete_text_templates'))), - - array('config.update', array('version', '3.0.7-rc1')), - ); - } - - public function delete_text_templates() - { - // Delete all text-templates from the template_data - $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); - $this->sql_query($sql); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php deleted file mode 100644 index 8167d8fa40..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ /dev/null @@ -1,73 +0,0 @@ -config['version'], '3.0.7-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_rc1'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_email_hash'))), - - array('config.update', array('version', '3.0.7-rc2')), - ); - } - - public function update_email_hash($start = 0) - { - $limit = 1000; - - $sql = 'SELECT user_id, user_email, user_email_hash - FROM ' . USERS_TABLE . ' - WHERE user_type <> ' . USER_IGNORE . " - AND user_email <> ''"; - $result = $this->db->sql_query_limit($sql, $limit, $start); - - $i = 0; - while ($row = $this->db->sql_fetchrow($result)) - { - $i++; - - // Snapshot of the phpbb_email_hash() function - // We cannot call it directly because the auto updater updates the DB first. :/ - $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); - - if ($user_email_hash != $row['user_email_hash']) - { - $sql_ary = array( - 'user_email_hash' => $user_email_hash, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $row['user_id']; - $this->sql_query($sql); - } - } - $this->db->sql_freeresult($result); - - if ($i < $limit) - { - // Completed - return; - } - - // Return the next start, will be sent to $start when this function is called again - return $start + $limit; - } -} diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php deleted file mode 100644 index 25baaf0f07..0000000000 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.8', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_8_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.8')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php deleted file mode 100644 index 13e68a7953..0000000000 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ /dev/null @@ -1,221 +0,0 @@ -config['version'], '3.0.8-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_pl1'); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_file_extension_group_names'))), - array('custom', array(array(&$this, 'update_module_auth'))), - array('custom', array(array(&$this, 'update_bots'))), - array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), - array('module.add', array( - 'acp', - 'ACP_MESSAGES', - array( - 'module_basename' => 'acp_board', - 'modes' => array('post'), - ), - )), - array('config.add', array('load_unreads_search', 1)), - array('config.update_if_equals', array(600, 'queue_interval', 60)), - array('config.update_if_equals', array(50, 'email_package_size', 20)), - - array('config.update', array('version', '3.0.8-rc1')), - ); - } - - public function update_file_extension_group_names() - { - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $this->db->sql_query($sql); - - $extension_groups_updated = array(); - while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) - { - $lang_dir = basename($lang_dir); - - // The language strings we need are either in language/.../acp/attachments.php - // in the update package if we're updating to 3.0.8-RC1 or later, - // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. - // On an already updated board, they can also already be in language/.../acp/attachments.php - // in the board root. - $lang_files = array( - "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", - "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", - "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", - ); - - foreach ($lang_files as $lang_file) - { - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; - $this->sql_query($sql); - - $extension_groups_updated[$lang_key] = true; - } - } - } - $this->db->sql_freeresult($result); - } - - public function update_module_auth() - { - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'avatar\''; - $this->sql_query($sql); - } - - public function update_bots() - { - $bot_name = 'Bing [Bot]'; - $bot_name_clean = utf8_clean_string($bot_name); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; - $result = $this->db->sql_query($sql); - $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); - $this->db->sql_freeresult($result); - - if (!$bing_already_added) - { - $bot_agent = 'bingbot/'; - $bot_ip = ''; - $sql = 'SELECT group_id, group_colour - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'BOTS'"; - $result = $this->db->sql_query($sql); - $group_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$group_row) - { - // default fallback, should never get here - $group_row['group_id'] = 6; - $group_row['group_colour'] = '9E8DA7'; - } - - if (!function_exists('user_add')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_row['group_id'], - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => $this->config['default_lang'], - 'user_style' => $this->config['default_style'], - 'user_timezone' => 0, - 'user_dateformat' => $this->config['default_dateformat'], - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => (string) $bot_name, - 'user_id' => (int) $user_id, - 'bot_agent' => (string) $bot_agent, - 'bot_ip' => (string) $bot_ip, - )); - - $this->sql_query($sql); - } - } - - public function delete_orphan_shadow_topics() - { - // Delete shadow topics pointing to not existing topics - $batch_size = 500; - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $this->db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); - $this->db->sql_query($sql); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - return false; - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php deleted file mode 100644 index b35350dbb5..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.9', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc4'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.9')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php deleted file mode 100644 index be6ced2566..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ /dev/null @@ -1,124 +0,0 @@ -config['version'], '3.0.9-rc1', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_8'); - } - - public function update_schema() - { - return array( - 'add_tables' => array( - $this->table_prefix . 'login_attempts' => array( - 'COLUMNS' => array( - // this column was removed from the database updater - // after 3.0.9-RC3 was released. It might still exist - // in 3.0.9-RCX installations and has to be dropped in - // 3.0.12 after the db_tools class is capable of properly - // removing a primary key. - // 'attempt_id' => array('UINT', NULL, 'auto_increment'), - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - //'PRIMARY_KEY' => 'attempt_id', - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'bbcodes' => array( - 'bbcode_id' => array('USINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_tables' => array( - $this->table_prefix . 'login_attempts', - ), - ); - } - - public function update_data() - { - 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'))), - - array('config.update', array('version', '3.0.9-rc1')), - ); - } - - public 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 ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); - $result = $this->db->sql_query($sql); - - 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 ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE group_id = ' . $row['group_id']; - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - } - - public 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 ($this->db_tools->sql_layer == 'firebird') - { - $tables = array( - $this->table_prefix . 'captcha_questions', - $this->table_prefix . 'captcha_answers', - $this->table_prefix . 'qa_confirm', - ); - foreach ($tables as $table) - { - if ($this->db_tools->sql_table_exists($table)) - { - $this->db_tools->sql_table_drop($table); - } - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php deleted file mode 100644 index 0bec42a8de..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.9-rc2', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc1'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php deleted file mode 100644 index a339670932..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.9-rc3', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc2'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php deleted file mode 100644 index ab5c302611..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ /dev/null @@ -1,28 +0,0 @@ -config['version'], '3.0.9-rc4', '>='); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc3'); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc4')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php deleted file mode 100644 index 8b437104e0..0000000000 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ /dev/null @@ -1,406 +0,0 @@ -config['version'], '3.1.0-dev', '>='); - } - - static public function depends_on() - { - return array( - 'phpbb_db_migration_data_3_0_11', - 'phpbb_db_migration_data_extensions', - 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone_p2', - 'phpbb_db_migration_data_reported_posts_display', - ); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'groups' => array( - 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), - ), - $this->table_prefix . 'profile_fields' => array( - 'field_show_on_pm' => array('BOOL', 0), - ), - $this->table_prefix . 'styles' => array( - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - $this->table_prefix . 'reports' => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'groups' => array( - 'group_legend' => array('UINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'groups' => array( - 'group_teampage', - ), - $this->table_prefix . 'profile_fields' => array( - 'field_show_on_pm', - ), - $this->table_prefix . 'styles' => array( - 'style_path', - 'bbcode_bitfield', - 'style_parent_id', - 'style_parent_tree', - ), - $this->table_prefix . 'reports' => array( - 'reported_post_text', - 'reported_post_uid', - 'reported_post_bitfield', - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), - - array('config.add', array('fulltext_postgres_ts_name', 'simple')), - array('config.add', array('fulltext_postgres_min_word_len', 4)), - array('config.add', array('fulltext_postgres_max_word_len', 254)), - array('config.add', array('fulltext_sphinx_stopwords', 0)), - array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), - - array('config.add', array('load_jquery_cdn', 0)), - array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), - - array('config.add', array('use_system_cron', 0)), - - array('config.add', array('legend_sort_groupname', 0)), - array('config.add', array('teampage_forums', 1)), - array('config.add', array('teampage_memberships', 1)), - - array('config.add', array('load_cpf_pm', 0)), - - array('config.add', array('display_last_subject', 1)), - - array('config.add', array('assets_version', 1)), - - array('config.add', array('site_home_url', '')), - array('config.add', array('site_home_text', '')), - - array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), - - array('module.add', array( - 'acp', - 'ACP_GROUPS', - array( - 'module_basename' => 'acp_groups', - 'modes' => array('position'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_ATTACHMENTS', - array( - 'module_basename' => 'acp_attachments', - 'modes' => array('manage'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_STYLE_MANAGEMENT', - array( - 'module_basename' => 'acp_styles', - 'modes' => array('install', 'cache'), - ), - )), - array('module.add', array( - 'ucp', - 'UCP_PROFILE', - array( - 'module_basename' => 'ucp_profile', - 'modes' => array('autologin_keys'), - ), - )), - // Module will be renamed later - array('module.add', array( - 'acp', - 'ACP_CAT_STYLES', - 'ACP_LANGUAGE' - )), - - array('module.remove', array( - 'acp', - false, - 'ACP_TEMPLATES', - )), - array('module.remove', array( - 'acp', - false, - 'ACP_THEMES', - )), - array('module.remove', array( - 'acp', - false, - 'ACP_IMAGESETS', - )), - - array('custom', array(array($this, 'rename_module_basenames'))), - array('custom', array(array($this, 'rename_styles_module'))), - array('custom', array(array($this, 'add_group_teampage'))), - array('custom', array(array($this, 'update_group_legend'))), - array('custom', array(array($this, 'localise_global_announcements'))), - array('custom', array(array($this, 'update_ucp_pm_basename'))), - array('custom', array(array($this, 'update_ucp_profile_auth'))), - array('custom', array(array($this, 'move_customise_modules'))), - - array('config.update', array('version', '3.1.0-dev')), - ); - } - - public function move_customise_modules() - { - // Move language management to new location in the Customise tab - // First get language module id - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_language'"; - $result = $this->db->sql_query($sql); - $language_module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - // Next get language management module id of the one just created - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_LANGUAGE'"; - $result = $this->db->sql_query($sql); - $language_management_module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - - if (!class_exists('acp_modules')) - { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); - } - // acp_modules calls adm_back_link, which is undefined at this point - if (!function_exists('adm_back_link')) - { - include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); - } - $module_manager = new acp_modules(); - $module_manager->module_class = 'acp'; - $module_manager->move_module($language_module_id, $language_management_module_id); - } - - public function update_ucp_pm_basename() - { - $sql = 'SELECT module_id, module_basename - FROM ' . MODULES_TABLE . " - WHERE module_basename <> 'ucp_pm' AND - module_langname='UCP_PM'"; - $result = $this->db->sql_query_limit($sql, 1); - - if ($row = $this->db->sql_fetchrow($result)) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['module_id']; - - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - } - - public function update_ucp_profile_auth() - { - // Update the auth setting for the module - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_auth = 'acl_u_chgprofileinfo' - WHERE module_class = 'ucp' - AND module_basename = 'ucp_profile' - AND module_mode = 'profile_info'"; - $this->sql_query($sql); - } - - public function rename_styles_module() - { - // Rename styles module to Customise - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_langname = 'ACP_CAT_CUSTOMISE' - WHERE module_langname = 'ACP_CAT_STYLES'"; - $this->sql_query($sql); - } - - public function rename_module_basenames() - { - // rename all module basenames to full classname - $sql = 'SELECT module_id, module_basename, module_class - FROM ' . MODULES_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $module_id = (int) $row['module_id']; - unset($row['module_id']); - - if (!empty($row['module_basename']) && !empty($row['module_class'])) - { - // all the class names start with class name or with phpbb_ for auto loading - if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && - strpos($row['module_basename'], 'phpbb_') !== 0) - { - $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; - - $sql_update = $this->db->sql_build_array('UPDATE', $row); - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET ' . $sql_update . ' - WHERE module_id = ' . $module_id; - $this->sql_query($sql); - } - } - } - - $this->db->sql_freeresult($result); - } - - public function add_group_teampage() - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 1 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'ADMINISTRATORS'"; - $this->sql_query($sql); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 2 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'GLOBAL_MODERATORS'"; - $this->sql_query($sql); - } - - public function update_group_legend() - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; - $result = $this->db->sql_query($sql); - - $next_legend = 1; - while ($row = $this->db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_legend = ' . $next_legend . ' - WHERE group_id = ' . (int) $row['group_id']; - $this->sql_query($sql); - - $next_legend++; - } - $this->db->sql_freeresult($result); - } - - public function localise_global_announcements() - { - // Localise Global Announcements - $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; - $result = $this->db->sql_query($sql); - - $global_announcements = $update_lastpost_data = array(); - $update_lastpost_data['forum_last_post_time'] = 0; - $update_forum_data = array( - 'forum_posts' => 0, - 'forum_topics' => 0, - 'forum_topics_real' => 0, - ); - - while ($row = $this->db->sql_fetchrow($result)) - { - $global_announcements[] = (int) $row['topic_id']; - - $update_forum_data['forum_posts'] += (int) $row['topic_posts']; - $update_forum_data['forum_topics_real']++; - if ($row['topic_approved']) - { - $update_forum_data['forum_topics']++; - } - - if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) - { - $update_lastpost_data = array( - 'forum_last_post_id' => (int) $row['topic_last_post_id'], - 'forum_last_post_subject' => $row['topic_last_post_subject'], - 'forum_last_post_time' => (int) $row['topic_last_post_time'], - 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], - 'forum_last_poster_name' => $row['topic_last_poster_name'], - 'forum_last_poster_colour' => $row['topic_last_poster_colour'], - ); - } - } - $this->db->sql_freeresult($result); - - if (!empty($global_announcements)) - { - // Update the post/topic-count for the forum and the last-post if needed - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - $result = $this->db->sql_query_limit($sql, 1); - $ga_forum_id = $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $ga_forum_id; - $result = $this->db->sql_query($sql); - $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); - $this->db->sql_freeresult($result); - - $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; - $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; - $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; - if ($lastpost < $update_lastpost_data['forum_last_post_time']) - { - $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $sql_update . ' - WHERE forum_id = ' . $ga_forum_id; - $this->sql_query($sql); - - // Update some forum_ids - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $ga_forum_id - WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); - $this->sql_query($sql); - } - unset($table_ary); - } - } -} diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php deleted file mode 100644 index f077741883..0000000000 --- a/phpBB/includes/db/migration/data/extensions.php +++ /dev/null @@ -1,69 +0,0 @@ -db_tools->sql_table_exists($this->table_prefix . 'ext'); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array( - 'add_tables' => array( - $this->table_prefix . 'ext' => array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_tables' => array( - $this->table_prefix . 'ext', - ), - ); - } - - public function update_data() - { - return array( - // Module will be renamed later - array('module.add', array( - 'acp', - 'ACP_CAT_STYLES', - 'ACP_EXTENSION_MANAGEMENT' - )), - array('module.add', array( - 'acp', - 'ACP_EXTENSION_MANAGEMENT', - array( - 'module_basename' => 'acp_extensions', - 'modes' => array('main'), - ), - )), - array('permission.add', array('a_extensions', true, 'a_styles')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/reported_posts_display.php b/phpBB/includes/db/migration/data/reported_posts_display.php deleted file mode 100644 index fa605e28e5..0000000000 --- a/phpBB/includes/db/migration/data/reported_posts_display.php +++ /dev/null @@ -1,42 +0,0 @@ -db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'reports' => array( - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'reports' => array( - 'reported_post_enable_bbcode', - 'reported_post_enable_smilies', - 'reported_post_enable_magic_url', - ), - ), - ); - } -} diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php deleted file mode 100644 index 7506b7c49b..0000000000 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ /dev/null @@ -1,157 +0,0 @@ -db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'styles_update'))), - ); - } - - public function styles_update() - { - // Get list of valid 3.1 styles - $available_styles = array('prosilver'); - - $iterator = new DirectoryIterator($this->phpbb_root_path . 'styles'); - $skip_dirs = array('.', '..', 'prosilver'); - foreach ($iterator as $fileinfo) - { - if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) - { - $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); - if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) - { - // 3.1 style - $available_styles[] = $fileinfo->getFilename(); - } - } - } - - // Get all installed styles - if ($this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset')) - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . 'styles_theme c, ' . $this->table_prefix . "styles_imageset i - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id - AND i.imageset_id = s.imageset_id"; - } - else - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id"; - } - $result = $this->db->sql_query($sql); - - $styles = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $styles[] = $row; - } - $this->db->sql_freeresult($result); - - // Decide which styles to keep, all others will be deleted - $valid_styles = array(); - foreach ($styles as $style_row) - { - if ( - // Delete styles with parent style (not supported yet) - $style_row['template_inherits_id'] == 0 && - // Check if components match - $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && - // Check if components are valid - in_array($style_row['template_path'], $available_styles) - ) - { - // Valid style. Keep it - $sql_ary = array( - 'style_path' => $style_row['template_path'], - 'bbcode_bitfield' => $style_row['bbcode_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - ); - $this->sql_query('UPDATE ' . STYLES_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE style_id = ' . $style_row['style_id']); - $valid_styles[] = (int) $style_row['style_id']; - } - } - - // Remove old entries from styles table - if (!sizeof($valid_styles)) - { - // No valid styles: remove everything and add prosilver - $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - - $sql_ary = array( - 'style_name' => 'prosilver', - 'style_copyright' => '© phpBB Group', - 'style_active' => 1, - 'style_path' => 'prosilver', - 'bbcode_bitfield' => 'lNg=', - 'style_parent_id' => 0, - 'style_parent_tree' => '', - - // Will be removed in the next step - 'imageset_id' => 0, - 'template_id' => 0, - 'theme_id' => 0, - ); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->sql_query($sql); - - $sql = 'SELECT style_id - FROM ' . $table . " - WHERE style_name = 'prosilver'"; - $result = $this->sql_query($sql); - $default_style = $this->db->sql_fetchfield($result); - $this->db->sql_freeresult($result); - - set_config('default_style', $default_style); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; - $this->sql_query($sql); - } - else - { - // There are valid styles in styles table. Remove styles that are outdated - $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' - WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); - - // Change default style - if (!in_array($this->config['default_style'], $valid_styles)) - { - $this->sql_query('UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . $valid_styles[0] . "' - WHERE config_name = 'default_style'"); - } - - // Reset styles for users - $this->sql_query('UPDATE ' . USERS_TABLE . ' - SET user_style = 0 - WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); - } - } -} diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php deleted file mode 100644 index ef13f45d9b..0000000000 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ /dev/null @@ -1,129 +0,0 @@ -db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_style_update_p1'); - } - - public function update_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'styles' => array( - 'imageset_id', - 'template_id', - 'theme_id', - ), - ), - - 'drop_tables' => array( - $this->table_prefix . 'styles_imageset', - $this->table_prefix . 'styles_imageset_data', - $this->table_prefix . 'styles_template', - $this->table_prefix . 'styles_template_data', - $this->table_prefix . 'styles_theme', - ), - ); - } - - public function revert_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'styles' => array( - 'imageset_id' => array('UINT', 0), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - ), - ), - - 'add_tables' => array( - $this->table_prefix . 'styles_imageset' => array( - 'COLUMNS' => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_name' => array('VCHAR_UNI:255', ''), - 'imageset_copyright' => array('VCHAR_UNI', ''), - 'imageset_path' => array('VCHAR:100', ''), - ), - 'PRIMARY_KEY' => 'imageset_id', - 'KEYS' => array( - 'imgset_nm' => array('UNIQUE', 'imageset_name'), - ), - ), - $this->table_prefix . 'styles_imageset_data' => array( - 'COLUMNS' => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'image_name' => array('VCHAR:200', ''), - 'image_filename' => array('VCHAR:200', ''), - 'image_lang' => array('VCHAR:30', ''), - 'image_height' => array('USINT', 0), - 'image_width' => array('USINT', 0), - 'imageset_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'image_id', - 'KEYS' => array( - 'i_d' => array('INDEX', 'imageset_id'), - ), - ), - $this->table_prefix . 'styles_template' => array( - 'COLUMNS' => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - 'template_name' => array('VCHAR_UNI:255', ''), - 'template_copyright' => array('VCHAR_UNI', ''), - 'template_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'template_storedb' => array('BOOL', 0), - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'template_id', - 'KEYS' => array( - 'tmplte_nm' => array('UNIQUE', 'template_name'), - ), - ), - $this->table_prefix . 'styles_template_data' => array( - 'COLUMNS' => array( - 'template_id' => array('UINT', 0), - 'template_filename' => array('VCHAR:100', ''), - 'template_included' => array('TEXT', ''), - 'template_mtime' => array('TIMESTAMP', 0), - 'template_data' => array('MTEXT_UNI', ''), - ), - 'KEYS' => array( - 'tid' => array('INDEX', 'template_id'), - 'tfn' => array('INDEX', 'template_filename'), - ), - ), - $this->table_prefix . 'styles_theme' => array( - 'COLUMNS' => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - 'theme_name' => array('VCHAR_UNI:255', ''), - 'theme_copyright' => array('VCHAR_UNI', ''), - 'theme_path' => array('VCHAR:100', ''), - 'theme_storedb' => array('BOOL', 0), - 'theme_mtime' => array('TIMESTAMP', 0), - 'theme_data' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'theme_id', - 'KEYS' => array( - 'theme_name' => array('UNIQUE', 'theme_name'), - ), - ), - ), - ); - } -} diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php deleted file mode 100644 index 66085b8872..0000000000 --- a/phpBB/includes/db/migration/data/timezone.php +++ /dev/null @@ -1,163 +0,0 @@ -db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'users' => array( - 'user_timezone' => array('VCHAR:100', ''), - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'update_timezones'))), - ); - } - - public function update_timezones() - { - // Update user timezones - $sql = 'SELECT user_dst, user_timezone - FROM ' . $this->table_prefix . 'users - GROUP BY user_timezone, user_dst'; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - - // Update board default timezone - $sql = 'UPDATE ' . $this->table_prefix . "config - SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' - WHERE config_name = 'board_timezone'"; - $this->sql_query($sql); - } - - /** - * Determine the new timezone for a given phpBB 3.0 timezone and - * "Daylight Saving Time" option - * - * @param $timezone float Users timezone in 3.0 - * @param $dst int Users daylight saving time - * @return string Users new php Timezone which is used since 3.1 - */ - public function convert_phpbb30_timezone($timezone, $dst) - { - $offset = $timezone + $dst; - - switch ($timezone) - { - case '-12': - return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time' - case '-11': - return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time' - case '-10': - return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' - case '-9.5': - return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' - case '-9': - return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time' - case '-8': - return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time' - case '-7': - return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time' - case '-6': - return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time' - case '-5': - return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time' - case '-4.5': - return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' - case '-4': - return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time' - case '-3.5': - return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' - case '-3': - return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time' - case '-2': - return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' - case '-1': - return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' - case '0': - return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time' - case '1': - return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time' - case '2': - return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' - case '3': - return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' - case '3.5': - return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' - case '4': - return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' - case '4.5': - return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' - case '5': - return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' - case '5.5': - return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' - case '5.75': - return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' - case '6': - return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' - case '6.5': - return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' - case '7': - return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' - case '8': - return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' - case '8.75': - return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' - case '9': - return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' - case '9.5': - return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' - case '10': - return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' - case '10.5': - return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' - case '11': - return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' - case '11.5': - return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' - case '12': - return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' - case '12.75': - return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' - case '13': - return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' - case '14': - return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' - default: - return 'UTC'; - } - } -} diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php deleted file mode 100644 index 38347a0c63..0000000000 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ /dev/null @@ -1,43 +0,0 @@ -db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); - } - - static public function depends_on() - { - return array('phpbb_db_migration_data_timezone'); - } - - public function update_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'users' => array( - 'user_dst', - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'users' => array( - 'user_dst' => array('BOOL', 0), - ), - ), - ); - } -} -- cgit v1.2.1 From e4afb68dc35131918a6b91ae9874ade97f448475 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 14 Jan 2013 12:50:13 -0600 Subject: [feature/migrations] Correct depends_on PHPBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 - phpBB/includes/db/migration/data/310/extensions.php | 2 +- phpBB/includes/db/migration/data/310/reported_posts_display.php | 5 +++++ phpBB/includes/db/migration/data/310/style_update_p1.php | 2 +- phpBB/includes/db/migration/data/310/timezone.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index f41750e327..13b36bbf30 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -17,7 +17,6 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration static public function depends_on() { return array( - 'phpbb_db_migration_data_30x_11', 'phpbb_db_migration_data_310_extensions', 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', diff --git a/phpBB/includes/db/migration/data/310/extensions.php b/phpBB/includes/db/migration/data/310/extensions.php index 925fa29384..6a9caa1cfc 100644 --- a/phpBB/includes/db/migration/data/310/extensions.php +++ b/phpBB/includes/db/migration/data/310/extensions.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_extensions extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/310/reported_posts_display.php b/phpBB/includes/db/migration/data/310/reported_posts_display.php index 64f0f1aaec..80a0a0e43f 100644 --- a/phpBB/includes/db/migration/data/310/reported_posts_display.php +++ b/phpBB/includes/db/migration/data/310/reported_posts_display.php @@ -14,6 +14,11 @@ class phpbb_db_migration_data_310_reported_posts_display extends phpbb_db_migrat return $this->db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); } + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + public function update_schema() { return array( diff --git a/phpBB/includes/db/migration/data/310/style_update_p1.php b/phpBB/includes/db/migration/data/310/style_update_p1.php index d19ccc37cf..e324ce7f24 100644 --- a/phpBB/includes/db/migration/data/310/style_update_p1.php +++ b/phpBB/includes/db/migration/data/310/style_update_p1.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_style_update_p1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/310/timezone.php b/phpBB/includes/db/migration/data/310/timezone.php index 7a6a9bce05..6e50cbe45f 100644 --- a/phpBB/includes/db/migration/data/310/timezone.php +++ b/phpBB/includes/db/migration/data/310/timezone.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_timezone extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_schema() -- cgit v1.2.1 From a665ad5c2e44922fbd9790597913091c68311533 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 15 Jan 2013 18:58:19 -0600 Subject: [feature/migrations] Remove user_msnm migration PHPBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 + .../includes/db/migration/data/310/remove_msnm.php | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/remove_msnm.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index 13b36bbf30..34f081bf62 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -21,6 +21,7 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', 'phpbb_db_migration_data_310_reported_posts_display', + 'phpbb_db_migration_data_310_remove_msnm', ); } diff --git a/phpBB/includes/db/migration/data/310/remove_msnm.php b/phpBB/includes/db/migration/data/310/remove_msnm.php new file mode 100644 index 0000000000..521161df6b --- /dev/null +++ b/phpBB/includes/db/migration/data/310/remove_msnm.php @@ -0,0 +1,43 @@ +db_tools->sql_column_exists($this->table_prefix . 'users', 'user_msnm'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm' => array('VCHAR_UNI', ''), + ), + ), + ); + } +} -- cgit v1.2.1 From 5705c3d377d097ef8bf7b99863eabc08fe3276e7 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 6 Feb 2013 13:14:40 -0600 Subject: [feature/migrations] Fix path to extension migrations PHPBB3-11318 --- phpBB/includes/extension/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 018324d5d6..008bd35376 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -520,7 +520,7 @@ class phpbb_extension_manager protected function handle_migrations($extension_name, $mode) { $migrator = $this->container->get('migrator'); - $migrations_path = $this->get_extension_path($extension_name) . 'migrations'; + $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; if (file_exists($migrations_path) && is_dir($migrations_path)) { $migrator->load_migrations($migrations_path); -- cgit v1.2.1 From a8da6b89e9da1d3b4e16317c21fc88fa1173d0f1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 20:01:40 -0600 Subject: [feature/migrations] Inject Migrator instead of using the container to fetch PHPBB3-11318 --- phpBB/includes/extension/manager.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 008bd35376..926cc015de 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -29,6 +29,7 @@ class phpbb_extension_manager protected $db; protected $config; + protected $migrator; protected $cache; protected $php_ext; protected $extensions; @@ -48,12 +49,13 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; + $this->migrator = $migrator; $this->cache = $cache; $this->php_ext = $php_ext; $this->extension_table = $extension_table; @@ -519,11 +521,10 @@ class phpbb_extension_manager */ protected function handle_migrations($extension_name, $mode) { - $migrator = $this->container->get('migrator'); $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; if (file_exists($migrations_path) && is_dir($migrations_path)) { - $migrator->load_migrations($migrations_path); + $this->migrator->load_migrations($migrations_path); } // What is a safe limit of execution time? Half the max execution time should be safe. @@ -532,9 +533,9 @@ class phpbb_extension_manager if ($mode == 'enable') { - while (!$migrator->finished()) + while (!$this->migrator->finished()) { - $migrator->update(); + $this->migrator->update(); // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $start_time) >= $safe_time_limit) @@ -545,9 +546,9 @@ class phpbb_extension_manager } else if ($mode == 'purge') { - while ($migrator->migration_state() !== false) + while ($this->migrator->migration_state() !== false) { - $migrator->revert(); + $this->migrator->revert(); // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $start_time) >= $safe_time_limit) -- cgit v1.2.1 From fc4d5f74c0b82989370e899939d6f31e9a85723d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 20:05:39 -0600 Subject: [feature/migrations] Call revert correctly when purging an extension PHPBB3-11318 --- phpBB/includes/extension/manager.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 926cc015de..21a9ec1370 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -522,11 +522,13 @@ class phpbb_extension_manager protected function handle_migrations($extension_name, $mode) { $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; - if (file_exists($migrations_path) && is_dir($migrations_path)) + if (!file_exists($migrations_path) || !is_dir($migrations_path)) { - $this->migrator->load_migrations($migrations_path); + return true; } + $migrations = $this->migrator->load_migrations($migrations_path); + // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); $start_time = time(); @@ -546,14 +548,17 @@ class phpbb_extension_manager } else if ($mode == 'purge') { - while ($this->migrator->migration_state() !== false) + foreach ($migrations as $migration) { - $this->migrator->revert(); - - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) + while ($this->migrator->migration_state($migration) !== false) { - return false; + $this->migrator->revert($migration); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } } } } -- cgit v1.2.1 From cacaffee6e013e43b75212d49960922f88f9f69a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 20:56:42 -0600 Subject: [feature/migrations] Add language strings for migrations errors Unfulfillable returns string of the missing dependency name now if the migration is unfulfillable (this is significantly more helpful). PHPBB3-11351 --- phpBB/includes/db/migration/tool/config.php | 2 +- phpBB/includes/db/migration/tool/module.php | 6 +++--- phpBB/includes/db/migration/tool/permission.php | 6 +++--- phpBB/includes/db/migrator.php | 16 +++++++++------- 4 files changed, 16 insertions(+), 14 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index d9cc20053e..458a25fb66 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -49,7 +49,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac { if (isset($this->config[$config_name])) { - throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); + throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXIST', $config_name); } $this->config->set($config_name, $config_value, !$is_dynamic); diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index afe1f21ec5..4d7fae2bb0 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -242,14 +242,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (!$module_id) { - throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent); } $parent = $data['parent_id'] = $module_id; } else if (!$this->exists($class, false, $parent)) { - throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent); } if ($this->exists($class, $parent, $data['module_langname'])) @@ -477,7 +477,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $result = $acp_modules->delete_module($module_id); if (!empty($result)) { - throw new phpbb_db_migration_exception('CANNOT_REMOVE_MODULE', $module_id); + throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result); } } diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 001d090f5a..4231fbe1dd 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -107,7 +107,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte { if ($this->exists($auth_option, $global)) { - throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXISTS', $auth_option); + throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXIST', $auth_option); } // We've added permissions, so set to true to notify the user. @@ -252,7 +252,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte if ($role_id) { - throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); + return; } $sql = 'SELECT MAX(role_order) AS max_role_order @@ -290,7 +290,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte if (!$role_id) { - throw new phpbb_db_migration_exception('ROLE_NOT_EXISTS', $old_role_name); + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $old_role_name); } $sql = 'UPDATE ' . ACL_ROLES_TABLE . " diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 4456600b0a..3c311e96d7 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -228,9 +228,10 @@ class phpbb_db_migrator { foreach ($this->migrations as $name) { - if ($this->unfulfillable($name)) + $unfulfillable = $this->unfulfillable($name); + if ($unfulfillable !== false) { - throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); + throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); } } } @@ -674,13 +675,13 @@ class phpbb_db_migrator * Checks if a migration's dependencies can even theoretically be satisfied. * * @param string $name The class name of the migration - * @return bool Whether the migration cannot be fulfilled + * @return bool|string False if fulfillable, string of missing migration name if unfulfillable */ public function unfulfillable($name) { if (isset($this->migration_state[$name])) { - return false; + return $name; } if (!class_exists($name)) @@ -693,9 +694,10 @@ class phpbb_db_migrator foreach ($depends as $depend) { - if ($this->unfulfillable($depend)) + $unfulfillable = $this->unfulfillable($depend); + if ($unfulfillable !== false) { - return true; + return $unfulfillable; } } @@ -715,7 +717,7 @@ class phpbb_db_migrator { // skip unfulfillable migrations, but fulfillables mean we // are not finished yet - if ($this->unfulfillable($name)) + if ($this->unfulfillable($name) !== false) { continue; } -- cgit v1.2.1 From b398fa2050ab720d9a3ae2b809bb3cdf4f153dc6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 21:09:29 -0600 Subject: [feature/migrations] Catch and display errors from the migrator PHPBB3-11318 --- phpBB/includes/acp/acp_extensions.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index a0bcf62ecc..17ab4f3169 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -37,7 +37,7 @@ class acp_extensions $this->template = $template; $this->user = $user; - $user->add_lang(array('install', 'acp/extensions')); + $user->add_lang(array('install', 'acp/extensions', 'migrator')); $this->page_title = 'ACP_EXTENSIONS'; @@ -103,11 +103,18 @@ class acp_extensions trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); } - if ($phpbb_extension_manager->enable_step($ext_name)) + try { - $template->assign_var('S_NEXT_STEP', true); + if ($phpbb_extension_manager->enable_step($ext_name)) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + } + } + catch (phpbb_db_migration_exception $e) + { + $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); } $this->tpl_name = 'acp_ext_enable'; @@ -156,11 +163,18 @@ class acp_extensions break; case 'purge': - if ($phpbb_extension_manager->purge_step($ext_name)) + try { - $template->assign_var('S_NEXT_STEP', true); + if ($phpbb_extension_manager->purge_step($ext_name)) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + } + } + catch (phpbb_db_migration_exception $e) + { + $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); } $this->tpl_name = 'acp_ext_purge'; -- cgit v1.2.1 From f18b096df945648aa3ecc2b8b914869871b1823f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 21:10:56 -0600 Subject: [feature/migrations] getParameters function for migration exception PHPBB3-11351 --- phpBB/includes/db/migration/exception.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index ffdcd97780..b3abcdb5e5 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -52,4 +52,14 @@ class phpbb_db_migration_exception extends \Exception { return $this->message . ': ' . var_export($this->parameters, true); } + + /** + * Get the parameters + * + * @return array + */ + public function getParameters() + { + return $this->parameters; + } } -- cgit v1.2.1 From f9a1b27a99e30a41db4facd415b39a690614d6c6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Feb 2013 21:16:39 -0600 Subject: [feature/migrations] Fix unfulfillable function Returned unfulfillable name in the wrong place previously PHPBB3-11351 --- phpBB/includes/db/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 3c311e96d7..41d996b1e3 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -681,12 +681,12 @@ class phpbb_db_migrator { if (isset($this->migration_state[$name])) { - return $name; + return false; } if (!class_exists($name)) { - return true; + return $name; } $migration = $this->get_migration($name); -- cgit v1.2.1 From 8ec55b062dbaf40f5ad3aec49bf987a14b34dfe8 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Mon, 11 Feb 2013 15:29:12 +0530 Subject: [ticket/11196] Changed 401 response message in session.php. In session.php 401 response message was "Not Authorized". I changed it to "Unauthorized". PHPBB3-11196 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 496c12a0d1..d980f50e05 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -325,7 +325,7 @@ class session // if no session id is set, redirect to index.php if (defined('NEED_SID') && (!isset($_GET['sid']) || $this->session_id !== $_GET['sid'])) { - send_status_line(401, 'Not authorized'); + send_status_line(401, 'Unauthorized'); redirect(append_sid("{$phpbb_root_path}index.$phpEx")); } -- cgit v1.2.1 From f6bb14569b0a777d3511b732201af9d1a415f2ed Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 15 Feb 2013 22:19:24 -0600 Subject: [feature/migrations] getLocalisedMessage function for migration exception PHPBB3-11351 --- phpBB/includes/db/migration/exception.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index b3abcdb5e5..e84330dd71 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -62,4 +62,18 @@ class phpbb_db_migration_exception extends \Exception { return $this->parameters; } + + /** + * Get localised message (with $user->lang()) + * + * @param phpbb_user $user + * @return string + */ + public function getLocalisedMessage(phpbb_user $user) + { + $parameters = $this->getParameters(); + array_unshift($parameters, $this->getMessage()); + + return call_user_func_array(array($user, 'lang'), $parameters); + } } -- cgit v1.2.1 From 872773a21897ccad754a53d7c8ad7899bcc05796 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 15 Feb 2013 22:22:13 -0600 Subject: [feature/migrations] Use getLocalisedMessage() function to get error message PHPBB3-11318 --- phpBB/includes/acp/acp_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 17ab4f3169..24211196bd 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -114,7 +114,7 @@ class acp_extensions } catch (phpbb_db_migration_exception $e) { - $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); + $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user)); } $this->tpl_name = 'acp_ext_enable'; @@ -174,7 +174,7 @@ class acp_extensions } catch (phpbb_db_migration_exception $e) { - $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); + $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user)); } $this->tpl_name = 'acp_ext_purge'; -- cgit v1.2.1 From 5b99f0c113390959f693222055715413addef34e Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 18 Feb 2013 14:01:46 +0530 Subject: [ticket/11359] close span PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 4bacf74f93..07bcbdadc1 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -878,7 +878,7 @@ class phpbb_search_fulltext_sphinx
' . $this->user->lang['MIB'] . '
-

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
+

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
'; -- cgit v1.2.1 From 3c6256b3e7489b9aca1e153b3e3bb754f3dd6a7d Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 18 Feb 2013 14:05:25 +0530 Subject: [ticket/11359] add id attribute to textarea PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 07bcbdadc1..6c66499d21 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -879,7 +879,7 @@ class phpbb_search_fulltext_sphinx

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
-
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
+
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
'; -- cgit v1.2.1 From 38360c71f298efee54396118b8afb5c642c79db3 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 18 Feb 2013 14:13:31 +0530 Subject: [ticket/11359] html escape sphinx config data PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 6c66499d21..7304e70ff8 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -879,7 +879,7 @@ class phpbb_search_fulltext_sphinx

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
-
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
+
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
'; -- cgit v1.2.1 From 737b99966de8e12ffa13d762b7065043a39399d7 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 03:39:51 +0530 Subject: [ticket/11179] add search query in case initial one fails changes the start parameter according to the total search results and executes the search query again to get the results. PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 34 ++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 324c214e91..acb1a7bde8 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -381,7 +381,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { return $result_count; } - $id_ary = array(); $join_topic = ($type == 'posts') ? false : true; @@ -490,7 +489,38 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if (!sizeof($id_ary)) { - return false; + $sql_count = "SELECT COUNT(*) as result_count + FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p + WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) + $sql_where_options + ORDER BY $sql_sort"; + $result = $this->db->sql_query($sql_count); + $total_match_count = (int) $this->db->sql_fetchfield('result_count'); + + if ($total_match_count) + { + if ($start < 0) + { + $start = 0; + } + else if ($start >= $total_match_count) + { + $start = floor(($total_match_count - 1) / $per_page) * $per_page; + } + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + } + + if (!sizeof($id_ary)) + { + return false; + } } // if the total result count is not cached yet, retrieve it from the db -- cgit v1.2.1 From 00d34617ccb6a53185f0e872a735b4dd2f65009b Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 13:36:14 +0100 Subject: [ticket/11179] correct the start parameter while retrieving from cache Start parameter if not between 0 and the total result count of the cached search results is changed accordingly PHPBB3-11179 --- phpBB/includes/search/base.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index b364dead9a..11e5535979 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -97,7 +97,6 @@ class phpbb_search_base function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) { global $cache; - if (!($stored_ids = $cache->get('_search_results_' . $search_key))) { // no search results cached for this search_key @@ -109,6 +108,19 @@ class phpbb_search_base $reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false; $complete = true; + // change start parameter in case out of bounds + if ($result_count) + { + if ($start < 0) + { + $start = 0; + } + else if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + } + // change the start to the actual end of the current request if the sort direction differs // from the dirction in the cache and reverse the ids later if ($reverse_ids) -- cgit v1.2.1 From 3e5ef8ab2cc1d8c6e0850e36ddb546489cc5ab12 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 13:39:40 +0100 Subject: [ticket/11179] pass start parameter by reference start parameter is passed by reference so that in case it is not in bounds the changes made to it are reflected back to the phpBB/search.php file PHPBB3-11179 --- phpBB/includes/search/base.php | 2 +- phpBB/includes/search/fulltext_mysql.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index 11e5535979..2047742367 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -94,7 +94,7 @@ class phpbb_search_base * * @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE */ - function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) + function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir) { global $cache; if (!($stored_ids = $cache->get('_search_results_' . $search_key))) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index acb1a7bde8..749353b2ee 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -353,7 +353,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts if (!$this->search_query) -- cgit v1.2.1 From 1c9c666ef193942a2d88ec59741ddc49900e92e9 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 14:17:38 +0100 Subject: [ticket/11179] use FOUND_ROWS query to re-search with changed start param PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 60 ++++++++++++-------------------- 1 file changed, 22 insertions(+), 38 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 749353b2ee..3ecc2cd39d 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -375,6 +375,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base implode(',', $author_ary) ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -487,47 +492,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $id_ary = array_unique($id_ary); - if (!sizeof($id_ary)) - { - $sql_count = "SELECT COUNT(*) as result_count - FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p - WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) - $sql_where_options - ORDER BY $sql_sort"; - $result = $this->db->sql_query($sql_count); - $total_match_count = (int) $this->db->sql_fetchfield('result_count'); - - if ($total_match_count) - { - if ($start < 0) - { - $start = 0; - } - else if ($start >= $total_match_count) - { - $start = floor(($total_match_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (!sizeof($id_ary)) - { - return false; - } - } - // if the total result count is not cached yet, retrieve it from the db if (!$result_count) { - $sql = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql); + $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; + $result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result); @@ -537,6 +506,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base } } + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); -- cgit v1.2.1 From 2601411a9cfb79de1c45523005e91f00a8583ad1 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 14:28:29 +0100 Subject: [ticket/11179] correct start parameter for author search PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 3ecc2cd39d..54e2007da3 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -571,6 +571,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $author_name, ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -676,8 +681,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // retrieve the total result count if needed if (!$result_count) { - $sql = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql); + $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; + $result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result); @@ -687,6 +692,20 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base } } + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); -- cgit v1.2.1 From 80f8e3abceabab658a5a935e5a6079e73f663698 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 14:29:39 +0100 Subject: [ticket/11179] pass start param by reference in author search PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 54e2007da3..69f76ba99e 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -547,7 +547,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) @@ -578,7 +578,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // try reading the results from cache $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) + if ($this->obtain_ids($search_key, $result_count, $id_ary, &$start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) { return $result_count; } -- cgit v1.2.1 From 2cb48f034153038d71d89ab58904cd048b8524d9 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 15:35:05 +0100 Subject: [ticket/11179] correct start parameter in psql keyword search PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index 1475cc31d0..d968a934f4 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -371,6 +371,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base implode(',', $author_ary) ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -495,11 +500,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $id_ary = array_unique($id_ary); - if (!sizeof($id_ary)) - { - return false; - } - // if the total result count is not cached yet, retrieve it from the db if (!$result_count) { @@ -518,6 +518,21 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $this->db->sql_transaction('commit'); + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); -- cgit v1.2.1 From ef88edbcf69541bd79e220c87c444b33a6751c67 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 15:44:16 +0100 Subject: [ticket/11179] correct start param in author search of postgres PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index d968a934f4..e8a5353b05 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -583,6 +583,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $author_name, ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -725,6 +730,20 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $this->db->sql_transaction('commit'); + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); -- cgit v1.2.1 From bc77ca4d4eb6a5bcf3e47706c6b6fd2b0fe33f82 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 10 Nov 2012 15:45:15 +0100 Subject: [ticket/11179] pass start param by reference in postgres PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index e8a5353b05..bdc2fa4f19 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -343,7 +343,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts if (!$this->search_query) @@ -559,7 +559,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) -- cgit v1.2.1 From 16bbdf4a52b2cb2fa4aa2cd607ae726ea1c7af67 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 11 Nov 2012 10:11:58 +0100 Subject: [ticket/11179] minor fixes Amends comments to start with capitals. Reinsert blank lines which were not supposed to be removed PHPBB3-11179 --- phpBB/includes/search/base.php | 3 ++- phpBB/includes/search/fulltext_mysql.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index 2047742367..914cef9167 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -97,6 +97,7 @@ class phpbb_search_base function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir) { global $cache; + if (!($stored_ids = $cache->get('_search_results_' . $search_key))) { // no search results cached for this search_key @@ -108,7 +109,7 @@ class phpbb_search_base $reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false; $complete = true; - // change start parameter in case out of bounds + // Change start parameter in case out of bounds if ($result_count) { if ($start < 0) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 69f76ba99e..ad5119f67c 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -386,6 +386,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { return $result_count; } + $id_ary = array(); $join_topic = ($type == 'posts') ? false : true; -- cgit v1.2.1 From f0d63594e68fa7a165b8ba90d0fcf35f38e42de9 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 2 Dec 2012 14:15:04 +0530 Subject: [ticket/11179] fix success query path for mysql Additional query to check start parameter executed only incase of no results. PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index ad5119f67c..4dc62753aa 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -510,17 +510,17 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); @@ -696,16 +696,16 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } if (sizeof($id_ary)) { -- cgit v1.2.1 From 8b7f306897cddcb16cbed50488848ee357c26f39 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 2 Dec 2012 14:31:12 +0530 Subject: [ticket/11179] fix success query path for postgres Additional query to check start parameter executed only incase of no results. PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index bdc2fa4f19..eeb628b18f 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -521,17 +521,17 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); @@ -733,16 +733,16 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } if (sizeof($id_ary)) { -- cgit v1.2.1 From a0ae223ef46e30c9413350ed7c4e52eaab5bb159 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 21 Dec 2012 19:10:48 +0530 Subject: [ticket/11179] correct start parameter in native keyword search PHPBB3-11179 --- phpBB/includes/search/fulltext_native.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 53df8348ae..fccdcd855e 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -516,7 +516,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts. if (empty($this->search_query)) @@ -855,10 +855,6 @@ class phpbb_search_fulltext_native extends phpbb_search_base } $this->db->sql_freeresult($result); - if (!sizeof($id_ary)) - { - return false; - } // if we use mysql and the total result count is not cached yet, retrieve it from the db if (!$total_results && $is_mysql) @@ -867,14 +863,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base $sql_array_copy = $sql_array; $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; - $sql = $this->db->sql_build_query('SELECT', $sql_array_copy); + $sql_calc = $this->db->sql_build_query('SELECT', $sql_array_copy); unset($sql_array_copy); - $this->db->sql_query($sql); + $this->db->sql_query($sql_calc); $this->db->sql_freeresult($result); - $sql = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql); + $sql_count = 'SELECT FOUND_ROWS() as total_results'; + $result = $this->db->sql_query($sql_count); $total_results = (int) $this->db->sql_fetchfield('total_results'); $this->db->sql_freeresult($result); @@ -884,6 +880,20 @@ class phpbb_search_fulltext_native extends phpbb_search_base } } + if ($start >= $total_results) + { + $start = floor(($total_results - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; + } + $this->db->sql_freeresult($result); + + } + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); -- cgit v1.2.1 From 2ff874fe930d458382212cfe5495080231ec76e6 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 21 Dec 2012 19:11:20 +0530 Subject: [ticket/11179] correct start parameter in native author search PHPBB3-11179 --- phpBB/includes/search/fulltext_native.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index fccdcd855e..c9f33054fc 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -920,7 +920,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) @@ -1106,13 +1106,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base if (!$total_results && $is_mysql) { // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. - $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); + $sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); - $this->db->sql_query($sql); + $this->db->sql_query($sql_calc); $this->db->sql_freeresult($result); - $sql = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql); + $sql_count = 'SELECT FOUND_ROWS() as total_results'; + $result = $this->db->sql_query($sql_count); $total_results = (int) $this->db->sql_fetchfield('total_results'); $this->db->sql_freeresult($result); @@ -1122,6 +1122,19 @@ class phpbb_search_fulltext_native extends phpbb_search_base } } + if ($start >= $total_results) + { + $start = floor(($total_results - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + } + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); -- cgit v1.2.1 From 38bb7dca31740f9d4f188b75167f736ee6666c2f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 21 Dec 2012 21:54:41 +0530 Subject: [ticket/11179] correct start parameter in sphinx search PHPBB3-11179 --- phpBB/includes/search/fulltext_sphinx.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 7304e70ff8..48445d0794 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -454,7 +454,7 @@ class phpbb_search_fulltext_sphinx * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts. if (!strlen($this->search_query) && !sizeof($author_ary)) @@ -609,6 +609,25 @@ class phpbb_search_fulltext_sphinx } } + $result_count = $result['total_found']; + + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + + $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + + // Could be connection to localhost:9312 failed (errno=111, + // msg=Connection refused) during rotate, retry if so + $retries = SPHINX_CONNECT_RETRIES; + while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) + { + usleep(SPHINX_CONNECT_WAIT_TIME); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + } + } + $id_ary = array(); if (isset($result['matches'])) { @@ -629,8 +648,6 @@ class phpbb_search_fulltext_sphinx return false; } - $result_count = $result['total_found']; - $id_ary = array_slice($id_ary, 0, (int) $per_page); return $result_count; -- cgit v1.2.1 From 1ee4702ec51ecfc7d40c8768ba7927439c73002c Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 25 Jan 2013 18:15:55 +0530 Subject: [ticket/11179] remove extra & in function call PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 4dc62753aa..adaf025730 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -579,7 +579,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // try reading the results from cache $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, &$start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) + if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) { return $result_count; } -- cgit v1.2.1 From ae3a22bd0c06bd6098c229963402d660572a0598 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Feb 2013 11:06:48 +0100 Subject: [ticket/11361] Make sure that array passed to strtr() has the proper format. The array $date_cache[$format]['lang'] passed to strtr() contains a sub-array which results in an E_NOTICE being thrown for 'Array to string conversion' on PHP 5.4. Ensure that the array passed to strtr() is one-dimensional by filtering out non-string values. PHPBB3-11361 --- phpBB/includes/session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index d980f50e05..b93f2ff65e 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2156,7 +2156,8 @@ class user extends session 'is_short' => strpos($format, '|'), 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), 'format_long' => str_replace('|', '', $format), - 'lang' => $this->lang['datetime'], + // Filter out values that are not strings (e.g. arrays) for strtr(). + 'lang' => array_filter($this->lang['datetime'], 'is_string'), ); // Short representation of month in format? Some languages use different terms for the long and short format of May -- cgit v1.2.1 From b7a222cdd593edb3e61183d9e28707ac9005aa82 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 23 Feb 2013 14:20:56 -0500 Subject: [ticket/11298] Fix typo in language key; EXTENSIONS -> EXTENSION PHPBB3-11298 --- phpBB/includes/acp/info/acp_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/info/acp_extensions.php b/phpBB/includes/acp/info/acp_extensions.php index 03d7059165..174b365af0 100644 --- a/phpBB/includes/acp/info/acp_extensions.php +++ b/phpBB/includes/acp/info/acp_extensions.php @@ -16,10 +16,10 @@ class acp_extensions_info { return array( 'filename' => 'acp_extensions', - 'title' => 'ACP_EXTENSIONS_MANAGEMENT', + 'title' => 'ACP_EXTENSION_MANAGEMENT', 'version' => '1.0.0', 'modes' => array( - 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')), + 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSION_MANAGEMENT')), ), ); } -- cgit v1.2.1 From 4bf64b5e38efd194b6ab41fcc5d62ee0cc6fad5a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 23 Feb 2013 15:10:21 -0600 Subject: [feature/migrations] Fully revert the removal of the user_msnm field PHBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index 34f081bf62..13b36bbf30 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -21,7 +21,6 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', 'phpbb_db_migration_data_310_reported_posts_display', - 'phpbb_db_migration_data_310_remove_msnm', ); } -- cgit v1.2.1 From e8b3e8498d9842296a905fdaad8c0c32e31bceb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 12:54:05 +0100 Subject: [ticket/7262] Backport set_config() and set_config_count() docs from develop. PHPBB3-7262 --- phpBB/includes/functions.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 571c863839..04b69f8c69 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -137,7 +137,14 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) } /** -* Set config value. Creates missing config entry. +* Sets a configuration option's value. +* +* @param string $config_name The configuration option's name +* @param string $config_value New configuration value +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config($config_name, $config_value, $is_dynamic = false) { @@ -166,7 +173,14 @@ function set_config($config_name, $config_value, $is_dynamic = false) } /** -* Set dynamic config value with arithmetic operation. +* Increments an integer config value directly in the database. +* +* @param string $config_name The configuration option's name +* @param int $increment Amount to increment by +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config_count($config_name, $increment, $is_dynamic = false) { -- cgit v1.2.1 From a9037a68c177d396b2ed4b9bfcaad64536a01aaa Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 13:03:48 +0100 Subject: [ticket/7262] Add $is_dynamic example to set_config() and set_config_count(). The logic is the other way around here in comparison to develop's phpbb_config_db class, so add examples to make things more clear. PHPBB3-7262 --- phpBB/includes/functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 04b69f8c69..2ca7d7f898 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -141,8 +141,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) * * @param string $config_name The configuration option's name * @param string $config_value New configuration value -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ @@ -177,8 +178,9 @@ function set_config($config_name, $config_value, $is_dynamic = false) * * @param string $config_name The configuration option's name * @param int $increment Amount to increment by -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ -- cgit v1.2.1 From 6bf64d5620b1b9f165a65b50042c391a29ef151c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 13:37:52 +0100 Subject: [ticket/7262] Add note about set_config() not updating is_dynamic. PHPBB3-7262 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2ca7d7f898..ccd2d3147c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -139,6 +139,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) /** * Sets a configuration option's value. * +* Please note that this function does not update the is_dynamic value for +* an already existing config option. +* * @param string $config_name The configuration option's name * @param string $config_value New configuration value * @param bool $is_dynamic Whether this variable should be cached (false) or -- cgit v1.2.1 From d2a15d9afe06509ff3e9fe5b6463800f66813783 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 24 Feb 2013 17:42:53 +0100 Subject: [ticket/10896] Add missing email validation lost in develop merge Fix incomplete merge, by adding a piece of code moved to another file in olympus back. PHPBB3-10896 --- phpBB/includes/functions_acp.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 32fd76e74d..d6bd9e35dd 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -443,6 +443,13 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) } break; + case 'email': + if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) + { + $error[] = $user->lang['EMAIL_INVALID_EMAIL']; + } + break; + // Absolute path case 'script_path': if (!$cfg_array[$config_name]) -- cgit v1.2.1 From f8e184c54e85dc55a803b76a6ccefb769ef38e17 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Mon, 18 Feb 2013 11:04:14 +0530 Subject: [ticket/11355] Wrong error message when no user is selected. In ACP group membership management, if you select 'remove member from group' without selecting any users and submit,it will display a wrong error after confirmbox. Since no users are selected, this should not go even until confirmbox. Added a new condition to check weather any users are selected when the action is 'deleteusers' in acp_groups.php and disply a correct error. PHPBB3-11355 --- phpBB/includes/acp/acp_groups.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 486616c33d..ec44f4fc0c 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -179,6 +179,10 @@ class acp_groups break; case 'deleteusers': + if (!$name_ary) + { + trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); + } case 'delete': if (!$group_id) { @@ -795,4 +799,4 @@ class acp_groups } } -?> \ No newline at end of file +?> -- cgit v1.2.1 From ab530a999ed64a2e1fcc10252bdae6d9139d7538 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Thu, 21 Feb 2013 22:47:42 +0530 Subject: [ticket/11355] Referred proper variable when validating selection. Earlier PR was referring wrong variable $name_ary. Changed it to $mark_ary which actually contains selected user ids. PHPBB3-11355 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index ec44f4fc0c..bbe85f8038 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -179,7 +179,7 @@ class acp_groups break; case 'deleteusers': - if (!$name_ary) + if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } -- cgit v1.2.1 From 373c9a3f4ea92f1bcbe63404a2b3bf356fe5abcb Mon Sep 17 00:00:00 2001 From: erangamapa Date: Mon, 18 Feb 2013 11:17:27 +0530 Subject: [ticket/11358] Success message even without selecting a user. In group membership management, if you perform the action 'Make group default for member' without selecting any user, a confirm box will be displayed and will show a success message after confirming. Added a new condition to fix this issue in acp_groups.php. It will check weather any users are selected before performing above action. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index bbe85f8038..dbe692aee0 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,6 +120,10 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } + else if (!$name_ary) + { + trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); + } if (confirm_box(true)) { -- cgit v1.2.1 From 880786d68610aff0c30573dc599af9e5b3ad56cf Mon Sep 17 00:00:00 2001 From: erangamapa Date: Thu, 21 Feb 2013 22:25:12 +0530 Subject: [ticket/11358] Removed redundant code and referred proper variable. Error was thrown when no users are selected before executing the code chunk which manually adds all the user to make the group default. Removed this code and referred $mark_ary instead of $name_ary which will not have selected user ids. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 42 ++------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index dbe692aee0..af25d9d014 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (!$name_ary) + else if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,45 +128,7 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - - if (!sizeof($mark_ary)) - { - $start = 0; - - do - { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - ORDER BY user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - $mark_ary = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $mark_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); - - $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - } - else - { - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); - } - + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else -- cgit v1.2.1 From 538b09ba6115a1f90821a18d045f2056e66b5178 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Fri, 22 Feb 2013 00:31:55 +0530 Subject: [ticket/11358] Enabled link making all users default for a group. Detect whether link is clicked or form is posted for making users default for a group. If form is posted and no users are selected, validation happens and displays an error message. When the link is clicked, all the users will be default users for that group. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index af25d9d014..c70327c6f1 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (empty($mark_ary)) + else if (empty($mark_ary) && $request->is_set_post('default')) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,7 +128,45 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + + if (!sizeof($mark_ary)) + { + $start = 0; + + do + { + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + ORDER BY user_id"; + $result = $db->sql_query_limit($sql, 200, $start); + + $mark_ary = array(); + if ($row = $db->sql_fetchrow($result)) + { + do + { + $mark_ary[] = $row['user_id']; + } + while ($row = $db->sql_fetchrow($result)); + + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + + $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + } + else + { + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + } + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else -- cgit v1.2.1 From c0a39537e38c350365c0baa74be31c000b1e9381 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Fri, 22 Feb 2013 09:53:49 +0530 Subject: [ticket/11358] Changed the action parameter value to represent the link. Changed the action parameter value to recognize whether 'Make default group for every member' is clicked. If so execute a seperate code block under switch statement for $action and add all the users as default for the group. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index c70327c6f1..33d5c16ed0 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (empty($mark_ary) && $request->is_set_post('default')) + else if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,9 +128,26 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - - if (!sizeof($mark_ary)) + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); + } + + break; + case 'defaultbylink': + if (confirm_box(true)) { + $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; + $start = 0; do @@ -161,27 +178,20 @@ class acp_groups $db->sql_freeresult($result); } while ($start); + + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else { - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); } - - trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - break; - case 'deleteusers': if (empty($mark_ary)) { @@ -691,7 +701,7 @@ class acp_groups 'U_ACTION' => $this->u_action . "&g=$group_id", 'U_BACK' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'), - 'U_DEFAULT_ALL' => "{$this->u_action}&action=default&g=$group_id", + 'U_DEFAULT_ALL' => "{$this->u_action}&action=defaultbylink&g=$group_id", )); // Grab the members -- cgit v1.2.1 From 1b39d6d65e2af632e6ad2ccba7fa2e61ab36c30c Mon Sep 17 00:00:00 2001 From: erangamapa Date: Sun, 24 Feb 2013 21:34:29 +0530 Subject: [ticket/11358] Changed the name of post parameter. Replaced the parameter name 'defaultbylink' to a meaningful name 'set_default_on_all'. Parameter is used for making all users default for selected group in acp_groups.php. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 33d5c16ed0..00ca26dfa6 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -143,7 +143,7 @@ class acp_groups } break; - case 'defaultbylink': + case 'set_default_on_all': if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; @@ -701,7 +701,7 @@ class acp_groups 'U_ACTION' => $this->u_action . "&g=$group_id", 'U_BACK' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'), - 'U_DEFAULT_ALL' => "{$this->u_action}&action=defaultbylink&g=$group_id", + 'U_DEFAULT_ALL' => "{$this->u_action}&action=set_default_on_all&g=$group_id", )); // Grab the members -- cgit v1.2.1 From 4615698807e17c55d5ab93e872f7efefb1e6acd7 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 24 Feb 2013 19:07:24 +0100 Subject: [ticket/10986] message.id fallback to SERVER_NAME or phpbb.generated Rather than send invalid message ids with a missing domain part we try to read one from $_SERVER and otherwise use phpbb.generated PHPBB3-10986 --- phpBB/includes/functions_messenger.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index e837811c86..db2dea33e8 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -389,6 +389,28 @@ class messenger } } + /** + * Generates a valid message id to be used in emails + * + * @return string message id + */ + function generate_message_id() + { + global $config; + + $domain = 'phpbb.generated'; + if ($config['server_name']) + { + $domain = $config['server_name']; + } + else if (!empty($_SERVER['SERVER_NAME'])) + { + $domain = $_SERVER['SERVER_NAME']; + } + + return md5(unique_id(time())) . '@' . $domain; + } + /** * Return email header */ @@ -415,7 +437,7 @@ class messenger $headers[] = 'Return-Path: <' . $config['board_email'] . '>'; $headers[] = 'Sender: <' . $config['board_email'] . '>'; $headers[] = 'MIME-Version: 1.0'; - $headers[] = 'Message-ID: <' . md5(unique_id(time())) . '@' . $config['server_name'] . '>'; + $headers[] = 'Message-ID: <' . $this->generate_message_id() . '>'; $headers[] = 'Date: ' . date('r', time()); $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit -- cgit v1.2.1 From 6045aa7aa2fb63358e3f736504b17533b1085712 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 25 Feb 2013 19:16:29 -0600 Subject: [ticket/11367] Migrator throws error if migrations table does not exist Force load_migration_state to not throw errors if the table does not exist. PHPBB3-11367 --- phpBB/includes/db/migrator.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 41d996b1e3..ea5de3372f 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -99,18 +99,26 @@ class phpbb_db_migrator { $this->migration_state = array(); + // prevent errors in case the table does not exist yet + $this->db->sql_return_on_error(true); + $sql = "SELECT * FROM " . $this->migrations_table; $result = $this->db->sql_query($sql); - while ($migration = $this->db->sql_fetchrow($result)) + if (!$this->db->sql_error_triggered) { - $this->migration_state[$migration['migration_name']] = $migration; + while ($migration = $this->db->sql_fetchrow($result)) + { + $this->migration_state[$migration['migration_name']] = $migration; + + $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + } - $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + $this->db->sql_freeresult($result); } - $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); } /** -- cgit v1.2.1 From 9a319fefb2ffed58da1d3339d59e53de09521e03 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 26 Feb 2013 10:22:13 -0600 Subject: [ticket/11367] Always freeresult PHPBB3-11367 --- phpBB/includes/db/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index ea5de3372f..74f71775f3 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -114,10 +114,10 @@ class phpbb_db_migrator $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); } - - $this->db->sql_freeresult($result); } + $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); } -- cgit v1.2.1