diff options
Diffstat (limited to 'phpBB/phpbb/db/migration')
90 files changed, 3655 insertions, 245 deletions
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php index 003ccf8f18..084d00a13a 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php @@ -57,7 +57,9 @@ class release_3_0_5_rc1 extends container_aware_migration public function hash_old_passwords() { + /* @var $passwords_manager \phpbb\passwords\manager */ $passwords_manager = $this->container->get('passwords.manager'); + $sql = 'SELECT user_id, user_password FROM ' . $this->table_prefix . 'users WHERE user_pass_convert = 1'; @@ -116,7 +118,7 @@ class release_3_0_5_rc1 extends container_aware_migration $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); + $this->db->sql_fetchrow($result); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php index faef68121d..40bb58c10d 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php @@ -153,7 +153,10 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration 'ACP_BOARD_CONFIGURATION', array( 'module_basename' => 'acp_board', - 'modes' => array('feed'), + 'module_langname' => 'ACP_FEED_SETTINGS', + 'module_mode' => 'feed', + 'module_auth' => 'acl_a_board', + 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS'), ), )), array('module.add', array( @@ -161,7 +164,11 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration 'ACP_CAT_USERS', array( 'module_basename' => 'acp_users', - 'modes' => array('warnings'), + 'module_langname' => 'ACP_USER_WARNINGS', + 'module_mode' => 'warnings', + 'module_auth' => 'acl_a_user', + 'module_display' => false, + 'after' => array('feedback', 'ACP_USER_FEEDBACK'), ), )), array('module.add', array( @@ -169,7 +176,9 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration 'ACP_SERVER_CONFIGURATION', array( 'module_basename' => 'acp_send_statistics', - 'modes' => array('send_statistics'), + 'module_langname' => 'ACP_SEND_STATISTICS', + 'module_mode' => 'send_statistics', + 'module_auth' => 'acl_a_server', ), )), array('module.add', array( @@ -177,7 +186,10 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration 'ACP_FORUM_BASED_PERMISSIONS', array( 'module_basename' => 'acp_permissions', - 'modes' => array('setting_forum_copy'), + 'module_langname' => 'ACP_FORUM_PERMISSIONS_COPY', + 'module_mode' => 'setting_forum_copy', + 'module_auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS'), ), )), array('module.add', array( @@ -185,7 +197,29 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration 'MCP_REPORTS', array( 'module_basename' => 'mcp_pm_reports', - 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), + 'module_langname' => 'MCP_PM_REPORTS_OPEN', + 'module_mode' => 'pm_reports', + 'module_auth' => 'acl_m_pm_report', + ), + )), + array('module.add', array( + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'mcp_pm_reports', + 'module_langname' => 'MCP_PM_REPORTS_CLOSED', + 'module_mode' => 'pm_reports_closed', + 'module_auth' => 'acl_m_pm_report', + ), + )), + array('module.add', array( + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'mcp_pm_reports', + 'module_langname' => 'MCP_PM_REPORT_DETAILS', + 'module_mode' => 'pm_report_details', + 'module_auth' => 'acl_m_pm_report', ), )), array('custom', array(array(&$this, 'add_newly_registered_group'))), diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php index 22fd51543b..836cb4577a 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php @@ -36,7 +36,10 @@ class release_3_0_8_rc1 extends \phpbb\db\migration\migration 'ACP_MESSAGES', array( 'module_basename' => 'acp_board', - 'modes' => array('post'), + 'module_langname' => 'ACP_POST_SETTINGS', + 'module_mode' => 'post', + 'module_auth' => 'acl_a_board', + 'after' => array('message', 'ACP_MESSAGE_SETTINGS'), ), )), array('config.add', array('load_unreads_search', 1)), @@ -55,9 +58,14 @@ class release_3_0_8_rc1 extends \phpbb\db\migration\migration $result = $this->db->sql_query($sql); $extension_groups_updated = array(); - while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) + while ($row = $this->db->sql_fetchrow($result)) { - $lang_dir = basename($lang_dir); + if (empty($row['lang_dir'])) + { + continue; + } + + $lang_dir = basename($row['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, diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php index 06e46d522f..5f928df47c 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php @@ -34,7 +34,7 @@ class release_3_0_9_rc1 extends \phpbb\db\migration\migration // 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 as - // soon as the db_tools class is capable of properly + // soon as the \phpbb\db\tools\tools class is capable of properly // removing a primary key. // 'attempt_id' => array('UINT', NULL, 'auto_increment'), 'attempt_ip' => array('VCHAR:40', ''), diff --git a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php index 0ca4f2f19c..725c57ca86 100644 --- a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php +++ b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v310; -class acp_prune_users_module extends \phpbb\db\migration\migration +class acp_prune_users_module extends \phpbb\db\migration\container_aware_migration { public function effectively_installed() { @@ -70,12 +70,7 @@ class acp_prune_users_module extends \phpbb\db\migration\migration $acp_cat_users_id = (int) $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); - } - $module_manager = new \acp_modules(); - $module_manager->module_class = 'acp'; - $module_manager->move_module($acp_prune_users_id, $acp_cat_users_id); + $module_manager = $this->container->get('module.manager'); + $module_manager->move_module($acp_prune_users_id, $acp_cat_users_id, 'acp'); } } diff --git a/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php index 2d51bd53e4..1e2024a071 100644 --- a/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php @@ -17,7 +17,12 @@ class auth_provider_oauth extends \phpbb\db\migration\migration { public function effectively_installed() { - return $this->db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth'); + return $this->db_tools->sql_table_exists($this->table_prefix . 'oauth_tokens'); + } + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v30x\release_3_0_0'); } public function update_schema() @@ -69,7 +74,9 @@ class auth_provider_oauth extends \phpbb\db\migration\migration 'UCP_PROFILE', array( 'module_basename' => 'ucp_auth_link', - 'modes' => array('auth_link'), + 'module_langname' => 'UCP_AUTH_LINK_MANAGE', + 'module_mode' => 'auth_link', + 'module_auth' => 'authmethod_oauth', ), )), ); diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php index 20bd547ac3..e48a9a1d3d 100644 --- a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -23,7 +23,9 @@ class contact_admin_acp_module extends \phpbb\db\migration\migration 'ACP_BOARD_CONFIGURATION', array( 'module_basename' => 'acp_contact', - 'modes' => array('contact'), + 'module_langname' => 'ACP_CONTACT_SETTINGS', + 'module_mode' => 'contact', + 'module_auth' => 'acl_a_board', ), )), ); diff --git a/phpBB/phpbb/db/migration/data/v310/dev.php b/phpBB/phpbb/db/migration/data/v310/dev.php index f037191c2a..9cc953ad8d 100644 --- a/phpBB/phpbb/db/migration/data/v310/dev.php +++ b/phpBB/phpbb/db/migration/data/v310/dev.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v310; -class dev extends \phpbb\db\migration\migration +class dev extends \phpbb\db\migration\container_aware_migration { public function effectively_installed() { @@ -125,7 +125,9 @@ class dev extends \phpbb\db\migration\migration 'ACP_GROUPS', array( 'module_basename' => 'acp_groups', - 'modes' => array('position'), + 'module_langname' => 'ACP_GROUPS_POSITION', + 'module_mode' => 'position', + 'module_auth' => 'acl_a_group', ), )), array('module.add', array( @@ -133,7 +135,9 @@ class dev extends \phpbb\db\migration\migration 'ACP_ATTACHMENTS', array( 'module_basename' => 'acp_attachments', - 'modes' => array('manage'), + 'module_langname' => 'ACP_MANAGE_ATTACHMENTS', + 'module_mode' => 'manage', + 'module_auth' => 'acl_a_attach', ), )), array('module.add', array( @@ -141,7 +145,19 @@ class dev extends \phpbb\db\migration\migration 'ACP_STYLE_MANAGEMENT', array( 'module_basename' => 'acp_styles', - 'modes' => array('install', 'cache'), + 'module_langname' => 'ACP_STYLES_INSTALL', + 'module_mode' => 'install', + 'module_auth' => 'acl_a_styles', + ), + )), + array('module.add', array( + 'acp', + 'ACP_STYLE_MANAGEMENT', + array( + 'module_basename' => 'acp_styles', + 'module_langname' => 'ACP_STYLES_CACHE', + 'module_mode' => 'cache', + 'module_auth' => 'acl_a_styles', ), )), array('module.add', array( @@ -149,7 +165,8 @@ class dev extends \phpbb\db\migration\migration 'UCP_PROFILE', array( 'module_basename' => 'ucp_profile', - 'modes' => array('autologin_keys'), + 'module_langname' => 'UCP_PROFILE_AUTOLOGIN_KEYS', + 'module_mode' => 'autologin_keys', ), )), // Module will be renamed later @@ -204,18 +221,13 @@ class dev extends \phpbb\db\migration\migration $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); + $module_manager = $this->container->get('module.manager'); + $module_manager->move_module($language_module_id, $language_management_module_id, 'acp'); } public function update_ucp_pm_basename() diff --git a/phpBB/phpbb/db/migration/data/v310/extensions.php b/phpBB/phpbb/db/migration/data/v310/extensions.php index 3171435482..2e7c5c5316 100644 --- a/phpBB/phpbb/db/migration/data/v310/extensions.php +++ b/phpBB/phpbb/db/migration/data/v310/extensions.php @@ -66,7 +66,9 @@ class extensions extends \phpbb\db\migration\migration 'ACP_EXTENSION_MANAGEMENT', array( 'module_basename' => 'acp_extensions', - 'modes' => array('main'), + 'module_langname' => 'ACP_EXTENSIONS', + 'module_mode' => 'main', + 'module_auth' => 'acl_a_extensions', ), )), array('permission.add', array('a_extensions', true, 'a_styles')), diff --git a/phpBB/phpbb/db/migration/data/v310/notifications.php b/phpBB/phpbb/db/migration/data/v310/notifications.php index f4d012b5ac..789aaa3ba9 100644 --- a/phpBB/phpbb/db/migration/data/v310/notifications.php +++ b/phpBB/phpbb/db/migration/data/v310/notifications.php @@ -85,7 +85,9 @@ class notifications extends \phpbb\db\migration\migration 'UCP_MAIN', array( 'module_basename' => 'ucp_notifications', - 'modes' => array('notification_list'), + 'module_langname' => 'UCP_NOTIFICATION_LIST', + 'module_mode' => 'notification_list', + 'module_auth' => 'cfg_allow_board_notifications', ), )), array('module.add', array( @@ -93,7 +95,8 @@ class notifications extends \phpbb\db\migration\migration 'UCP_PREFS', array( 'module_basename' => 'ucp_notifications', - 'modes' => array('notification_options'), + 'module_langname' => 'UCP_NOTIFICATION_OPTIONS', + 'module_mode' => 'notification_options', ), )), array('config.add', array('load_notifications', 1)), diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php index 5e68db5889..90dab991e1 100644 --- a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php +++ b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php @@ -45,7 +45,9 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration 'MCP_QUEUE', array( 'module_basename' => 'mcp_queue', - 'modes' => array('deleted_topics'), + 'module_langname' => 'MCP_QUEUE_DELETED_TOPICS', + 'module_mode' => 'deleted_topics', + 'module_auth' => 'aclf_m_approve', ), )), array('module.add', array( @@ -53,7 +55,9 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration 'MCP_QUEUE', array( 'module_basename' => 'mcp_queue', - 'modes' => array('deleted_posts'), + 'module_langname' => 'MCP_QUEUE_DELETED_POSTS', + 'module_mode' => 'deleted_posts', + 'module_auth' => 'aclf_m_approve', ), )), ); diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php index 2c7b7edf2e..a7e30a9cb7 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php @@ -133,7 +133,7 @@ class style_update_p1 extends \phpbb\db\migration\migration } // Remove old entries from styles table - if (!sizeof($valid_styles)) + if (!count($valid_styles)) { // No valid styles: remove everything and add prosilver $this->sql_query('DELETE FROM ' . STYLES_TABLE); @@ -160,12 +160,12 @@ class style_update_p1 extends \phpbb\db\migration\migration FROM ' . STYLES_TABLE . " WHERE style_name = 'prosilver'"; $result = $this->sql_query($sql); - $default_style = $this->db->sql_fetchfield('style_id'); + $default_style = (int) $this->db->sql_fetchfield('style_id'); $this->db->sql_freeresult($result); $this->config->set('default_style', $default_style); - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = ' . (int) $default_style; $this->sql_query($sql); } else @@ -183,9 +183,9 @@ class style_update_p1 extends \phpbb\db\migration\migration } // 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)); + $this->sql_query('UPDATE ' . USERS_TABLE . " + SET user_style = '" . (int) $valid_styles[0] . "' + WHERE " . $this->db->sql_in_set('user_style', $valid_styles, true)); } } } diff --git a/phpBB/phpbb/db/migration/data/v310/teampage.php b/phpBB/phpbb/db/migration/data/v310/teampage.php index f8edbc3492..3a37b17e97 100644 --- a/phpBB/phpbb/db/migration/data/v310/teampage.php +++ b/phpBB/phpbb/db/migration/data/v310/teampage.php @@ -93,13 +93,13 @@ class teampage extends \phpbb\db\migration\migration $teampage_entries[] = array( 'group_id' => (int) $row['group_id'], 'teampage_name' => '', - 'teampage_position' => sizeof($teampage_entries) + 1, + 'teampage_position' => count($teampage_entries) + 1, 'teampage_parent' => 0, ); } $this->db->sql_freeresult($result); - if (sizeof($teampage_entries)) + if (count($teampage_entries)) { $this->db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_entries); } diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index 1f6b47ad50..03a8d1ab34 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -103,7 +103,7 @@ class timezone extends \phpbb\db\migration\migration */ public function convert_phpbb30_timezone($timezone, $dst) { - $offset = $timezone + $dst; + $offset = (float) $timezone + (int) $dst; switch ($timezone) { diff --git a/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php index 854ed1f568..14b7b7b0f6 100644 --- a/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php +++ b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php @@ -45,7 +45,6 @@ class update_custom_bbcodes_with_idn extends \phpbb\db\migration\migration $sql_ary = array(); while ($row = $this->db->sql_fetchrow($result)) { - $data = array(); if (preg_match('/(URL|LOCAL_URL|RELATIVE_URL)/', $row['bbcode_match'])) { $data = $bbcodes->build_regexp($row['bbcode_match'], $row['bbcode_tpl']); diff --git a/phpBB/phpbb/db/migration/data/v31x/v3112.php b/phpBB/phpbb/db/migration/data/v31x/v3112.php new file mode 100644 index 0000000000..0d75d35184 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v3112.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v31x; + +class v3112 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.1.12', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v3111', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.1.12')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/.htaccess b/phpBB/phpbb/db/migration/data/v320/.htaccess new file mode 100644 index 0000000000..44242b5418 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/.htaccess @@ -0,0 +1,33 @@ +# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from +# module mod_authz_host to a new module called mod_access_compat (which may be +# disabled) and a new "Require" syntax has been introduced to mod_authz_host. +# We could just conditionally provide both versions, but unfortunately Apache +# does not explicitly tell us its version if the module mod_version is not +# available. In this case, we check for the availability of module +# mod_authz_core (which should be on 2.4 or higher only) as a best guess. +<IfModule mod_version.c> + <IfVersion < 2.4> + <Files "*"> + Order Allow,Deny + Deny from All + </Files> + </IfVersion> + <IfVersion >= 2.4> + <Files "*"> + Require all denied + </Files> + </IfVersion> +</IfModule> +<IfModule !mod_version.c> + <IfModule !mod_authz_core.c> + <Files "*"> + Order Allow,Deny + Deny from All + </Files> + </IfModule> + <IfModule mod_authz_core.c> + <Files "*"> + Require all denied + </Files> + </IfModule> +</IfModule> diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php new file mode 100644 index 0000000000..804adc4490 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php @@ -0,0 +1,48 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class add_help_phpbb extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320rc1', + ); + } + + public function effectively_installed() + { + return isset($this->config['help_send_statistics']); + } + + public function update_data() + { + return array( + array('config.add', array('help_send_statistics', true)), + array('config.add', array('help_send_statistics_time', 0)), + array('module.remove', array('acp', false, 'ACP_SEND_STATISTICS')), + array('module.add', array( + 'acp', + 'ACP_SERVER_CONFIGURATION', + array( + 'module_basename' => 'acp_help_phpbb', + 'module_langname' => 'ACP_HELP_PHPBB', + 'module_mode' => 'help_phpbb', + 'module_auth' => 'acl_a_server', + ), + )), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php new file mode 100644 index 0000000000..726822bc71 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class allowed_schemes_links extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_data() + { + return array( + array('config.add', array('allowed_schemes_links', 'http,https,ftp')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php new file mode 100644 index 0000000000..7afecb884b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php @@ -0,0 +1,43 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class announce_global_permission extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = 'f_announce_global'"; + $result = $this->db->sql_query($sql); + $auth_option_id = $this->db->sql_fetchfield('auth_option_id'); + $this->db->sql_freeresult($result); + + return $auth_option_id !== false; + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_data() + { + return array( + array('permission.add', array('f_announce_global', false, 'f_announce')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/cookie_notice.php b/phpBB/phpbb/db/migration/data/v320/cookie_notice.php new file mode 100644 index 0000000000..75cb03b3ef --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/cookie_notice.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class cookie_notice extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320rc2', + ); + } + + public function update_data() + { + return array( + array('config.add', array('cookie_notice', false)), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php b/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php new file mode 100644 index 0000000000..65e5b3fa73 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/default_data_type_ids.php @@ -0,0 +1,361 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class default_data_type_ids extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320a2', + '\phpbb\db\migration\data\v320\oauth_states', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'acl_users' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'attachments' => array( + 'attach_id' => array('ULINT', null, 'auto_increment'), + 'post_msg_id' => array('ULINT', 0), + 'poster_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'banlist' => array( + 'ban_id' => array('ULINT', null, 'auto_increment'), + 'ban_userid' => array('ULINT', 0), + ), + $this->table_prefix . 'bookmarks' => array( + 'topic_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'bots' => array( + 'bot_id' => array('ULINT', null, 'auto_increment'), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'drafts' => array( + 'draft_id' => array('ULINT', null, 'auto_increment'), + 'user_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_id' => array('ULINT', 0), + 'forum_last_poster_id' => array('ULINT', 0), + ), + $this->table_prefix . 'forums_access' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'forums_track' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'forums_watch' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'log' => array( + 'log_id' => array('ULINT', null, 'auto_increment'), + 'post_id' => array('ULINT', 0), + 'reportee_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'login_attempts' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'moderator_cache' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'notifications' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'oauth_accounts' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'oauth_states' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'oauth_tokens' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'poll_options' => array( + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'poll_votes' => array( + 'topic_id' => array('ULINT', 0), + 'vote_user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'posts' => array( + 'post_id' => array('ULINT', null, 'auto_increment'), + 'poster_id' => array('ULINT', 0), + 'post_delete_user' => array('ULINT', 0), + 'post_edit_user' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'privmsgs' => array( + 'author_id' => array('ULINT', 0), + 'message_edit_user' => array('ULINT', 0), + 'msg_id' => array('ULINT', null, 'auto_increment'), + ), + $this->table_prefix . 'privmsgs_folder' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'privmsgs_rules' => array( + 'rule_user_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'privmsgs_to' => array( + 'author_id' => array('ULINT', 0), + 'msg_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'profile_fields_data' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'reports' => array( + 'report_id' => array('ULINT', 0), + 'pm_id' => array('ULINT', 0), + 'post_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'search_wordlist' => array( + 'word_id' => array('ULINT', null, 'auto_increment'), + ), + $this->table_prefix . 'search_wordmatch' => array( + 'post_id' => array('ULINT', 0), + 'word_id' => array('ULINT', 0), + ), + $this->table_prefix . 'sessions' => array( + 'session_user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'sessions_keys' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'topics' => array( + 'topic_id' => array('ULINT', null, 'auto_increment'), + 'topic_poster' => array('ULINT', 0), + 'topic_first_post_id' => array('ULINT', 0), + 'topic_last_post_id' => array('ULINT', 0), + 'topic_last_poster_id' => array('ULINT', 0), + 'topic_moved_id' => array('ULINT', 0), + 'topic_delete_user' => array('ULINT', 0), + ), + $this->table_prefix . 'topics_track' => array( + 'user_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'topics_posted' => array( + 'user_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'topics_watch' => array( + 'user_id' => array('ULINT', 0), + 'topic_id' => array('ULINT', 0), + ), + $this->table_prefix . 'user_notifications' => array( + 'item_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'user_group' => array( + 'user_id' => array('ULINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_id' => array('ULINT', null, 'auto_increment'), + ), + $this->table_prefix . 'warnings' => array( + 'log_id' => array('ULINT', 0), + 'user_id' => array('ULINT', 0), + 'post_id' => array('ULINT', 0), + ), + $this->table_prefix . 'words' => array( + 'word_id' => array('ULINT', null, 'auto_increment'), + ), + $this->table_prefix . 'zebra' => array( + 'user_id' => array('ULINT', 0), + 'zebra_id' => array('ULINT', 0), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'acl_users' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'attachments' => array( + 'attach_id' => array('UINT', null, 'auto_increment'), + 'post_msg_id' => array('UINT', 0), + 'poster_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'banlist' => array( + 'ban_id' => array('UINT', null, 'auto_increment'), + 'ban_userid' => array('UINT', 0), + ), + $this->table_prefix . 'bookmarks' => array( + 'topic_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'bots' => array( + 'bot_id' => array('UINT', null, 'auto_increment'), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'drafts' => array( + 'draft_id' => array('UINT', null, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_id' => array('UINT', 0), + 'forum_last_poster_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums_access' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums_track' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums_watch' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'log' => array( + 'log_id' => array('UINT', null, 'auto_increment'), + 'post_id' => array('UINT', 0), + 'reportee_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'login_attempts' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'moderator_cache' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'notifications' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'oauth_accounts' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'oauth_states' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'oauth_tokens' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'poll_options' => array( + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'poll_votes' => array( + 'topic_id' => array('UINT', 0), + 'vote_user_id' => array('UINT', 0), + ), + $this->table_prefix . 'posts' => array( + 'post_id' => array('UINT', null, 'auto_increment'), + 'poster_id' => array('UINT', 0), + 'post_delete_user' => array('UINT', 0), + 'post_edit_user' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'privmsgs' => array( + 'author_id' => array('UINT', 0), + 'message_edit_user' => array('UINT', 0), + 'msg_id' => array('UINT', null, 'auto_increment'), + ), + $this->table_prefix . 'privmsgs_folder' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'privmsgs_rules' => array( + 'rule_user_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'privmsgs_to' => array( + 'author_id' => array('UINT', 0), + 'msg_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'profile_fields_data' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'reports' => array( + 'report_id' => array('UINT', 0), + 'pm_id' => array('UINT', 0), + 'post_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'search_wordlist' => array( + 'word_id' => array('UINT', null, 'auto_increment'), + ), + $this->table_prefix . 'search_wordmatch' => array( + 'post_id' => array('UINT', 0), + 'word_id' => array('UINT', 0), + ), + $this->table_prefix . 'sessions' => array( + 'session_user_id' => array('UINT', 0), + ), + $this->table_prefix . 'sessions_keys' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'topics' => array( + 'topic_id' => array('UINT', null, 'auto_increment'), + 'topic_poster' => array('UINT', 0), + 'topic_first_post_id' => array('UINT', 0), + 'topic_last_post_id' => array('UINT', 0), + 'topic_last_poster_id' => array('UINT', 0), + 'topic_moved_id' => array('UINT', 0), + 'topic_delete_user' => array('UINT', 0), + ), + $this->table_prefix . 'topics_track' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'topics_posted' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'topics_watch' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + ), + $this->table_prefix . 'user_notifications' => array( + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'user_group' => array( + 'user_id' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_id' => array('UINT', null, 'auto_increment'), + ), + $this->table_prefix . 'warnings' => array( + 'log_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'post_id' => array('UINT', 0), + ), + $this->table_prefix . 'words' => array( + 'word_id' => array('UINT', null, 'auto_increment'), + ), + $this->table_prefix . 'zebra' => array( + 'user_id' => array('UINT', 0), + 'zebra_id' => array('UINT', 0), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/dev.php b/phpBB/phpbb/db/migration/data/v320/dev.php new file mode 100644 index 0000000000..ad2da3c1f4 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/dev.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class dev extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-dev', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v316', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-dev')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php new file mode 100644 index 0000000000..817b638037 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class font_awesome_update extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function effectively_installed() + { + return isset($this->config['load_font_awesome_url']); + } + + public function update_data() + { + return array( + array('config.add', array('load_font_awesome_url', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/icons_alt.php b/phpBB/phpbb/db/migration/data/v320/icons_alt.php new file mode 100644 index 0000000000..80132e579e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/icons_alt.php @@ -0,0 +1,46 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class icons_alt extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'icons' => array( + 'icons_alt' => array('VCHAR', '', 'after' => 'icons_height'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'icons' => array( + 'icons_alt', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/log_post_id.php b/phpBB/phpbb/db/migration/data/v320/log_post_id.php new file mode 100644 index 0000000000..ead53c8138 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/log_post_id.php @@ -0,0 +1,46 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class log_post_id extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'log' => array( + 'post_id' => array('UINT', 0, 'after' => 'topic_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'log' => array( + 'post_id', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/notifications_board.php b/phpBB/phpbb/db/migration/data/v320/notifications_board.php new file mode 100644 index 0000000000..ac1b3a0f2c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/notifications_board.php @@ -0,0 +1,75 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class notifications_board extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_data() + { + return array( + array('config.add', array('allow_board_notifications', 1)), + array('custom', array(array($this, 'update_user_subscriptions'))), + array('custom', array(array($this, 'update_module'))), + ); + } + + public function update_module() + { + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'cfg_allow_board_notifications' + WHERE module_basename = 'ucp_notifications' + AND module_mode = 'notification_list'"; + $this->sql_query($sql); + } + + public function update_user_subscriptions() + { + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET method = 'notification.method.board' + WHERE method = ''"; + $this->sql_query($sql); + } + + public function revert_data() + { + return array( + array('custom', array(array($this, 'revert_user_subscriptions'))), + array('custom', array(array($this, 'revert_module'))), + ); + } + + public function revert_user_subscriptions() + { + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET method = '' + WHERE method = 'notification.method.board'"; + $this->sql_query($sql); + } + + public function revert_module() + { + $sql = 'UPDATE ' . MODULES_TABLE . " + SET auth = '' + WHERE module_basename = 'ucp_notifications' + AND module_mode = 'notification_list'"; + $this->sql_query($sql); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/oauth_states.php b/phpBB/phpbb/db/migration/data/v320/oauth_states.php new file mode 100644 index 0000000000..22ab2dabb3 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/oauth_states.php @@ -0,0 +1,56 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class oauth_states extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\auth_provider_oauth'); + } + + public function effectively_installed() + { + return $this->db_tools->sql_table_exists($this->table_prefix . 'oauth_states'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'oauth_states' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'session_id' => array('CHAR:32', ''), + 'provider' => array('VCHAR', ''), + 'oauth_state' => array('VCHAR', ''), + ), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'provider' => array('INDEX', 'provider'), + ), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'oauth_states', + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php b/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php new file mode 100644 index 0000000000..d61f6b96fd --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/remote_upload_validation.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class remote_upload_validation extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320a2', + ); + } + + public function update_data() + { + return array( + array('config.add', array('remote_upload_verify', '0')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php new file mode 100644 index 0000000000..88fe59ccc9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php @@ -0,0 +1,95 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class remove_outdated_media extends \phpbb\db\migration\migration +{ + // Following constants were deprecated in 3.2 + // and moved from constants.php to compatibility_globals.php, + // thus define them as class constants + const ATTACHMENT_CATEGORY_WM = 2; + const ATTACHMENT_CATEGORY_RM = 3; + const ATTACHMENT_CATEGORY_QUICKTIME = 6; + + protected $cat_id = array( + self::ATTACHMENT_CATEGORY_WM, + self::ATTACHMENT_CATEGORY_RM, + self::ATTACHMENT_CATEGORY_QUICKTIME, + ); + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'change_extension_group'))), + ); + } + + public function change_extension_group() + { + // select group ids of outdated media + $sql = 'SELECT group_id + FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id); + $result = $this->db->sql_query($sql); + + $group_ids = array(); + while ($group_id = (int) $this->db->sql_fetchfield('group_id')) + { + $group_ids[] = $group_id; + } + $this->db->sql_freeresult($result); + + // nothing to do, admin has removed all the outdated media extension groups + if (empty($group_ids)) + { + return true; + } + + // get the group id of downloadable files + $sql = 'SELECT group_id + FROM ' . EXTENSION_GROUPS_TABLE . " + WHERE group_name = 'DOWNLOADABLE_FILES'"; + $result = $this->db->sql_query($sql); + $download_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); + + if (empty($download_id)) + { + $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' + SET group_id = 0 + WHERE ' . $this->db->sql_in_set('group_id', $group_ids); + } + else + { + // move outdated media extensions to downloadable files + $sql = 'UPDATE ' . EXTENSIONS_TABLE . " + SET group_id = $download_id" . ' + WHERE ' . $this->db->sql_in_set('group_id', $group_ids); + } + + $this->db->sql_query($sql); + + // delete the now empty, outdated media extension groups + $sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE ' . $this->db->sql_in_set('group_id', $group_ids); + $this->db->sql_query($sql); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php new file mode 100644 index 0000000000..1cb9070bf9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php @@ -0,0 +1,152 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class remove_profilefield_wlm extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_phpbb_wlm', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields_data' => array( + 'pf_phpbb_wlm' => array('VCHAR', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'delete_custom_profile_field_data'))), + ); + } + + public function revert_data() + { + return array( + array('custom', array(array($this, 'create_custom_field'))), + ); + } + + public function delete_custom_profile_field_data() + { + $field_id = $this->get_custom_profile_field_id(); + + $sql = 'DELETE FROM ' . PROFILE_FIELDS_TABLE . ' + WHERE field_id = ' . (int) $field_id; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' + WHERE field_id = ' . (int) $field_id; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' + WHERE field_id = ' . (int) $field_id; + $this->db->sql_query($sql); + } + + /** + * Get custom profile field id + * @return int custom profile filed id + */ + public function get_custom_profile_field_id() + { + $sql = 'SELECT field_id + FROM ' . PROFILE_FIELDS_TABLE . " + WHERE field_name = 'phpbb_wlm'"; + $result = $this->db->sql_query($sql); + $field_id = (int) $this->db->sql_fetchfield('field_id'); + $this->db->sql_freeresult($result); + + return $field_id; + } + + public function create_custom_field() + { + $sql = 'SELECT MAX(field_order) as max_field_order + FROM ' . PROFILE_FIELDS_TABLE; + $result = $this->db->sql_query($sql); + $max_field_order = (int) $this->db->sql_fetchfield('max_field_order'); + $this->db->sql_freeresult($result); + + $sql_ary = array( + 'field_name' => 'phpbb_wlm', + 'field_type' => 'profilefields.type.string', + 'field_ident' => 'phpbb_wlm', + 'field_length' => '40', + 'field_minlen' => '5', + 'field_maxlen' => '255', + 'field_novalue' => '', + 'field_default_value' => '', + 'field_validation' => '.*', + 'field_required' => 0, + 'field_show_novalue' => 0, + 'field_show_on_reg' => 0, + 'field_show_on_pm' => 1, + 'field_show_on_vt' => 1, + 'field_show_on_ml' => 0, + 'field_show_profile' => 1, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_active' => 1, + 'field_is_contact' => 1, + 'field_contact_desc' => '', + 'field_contact_url' => '', + 'field_order' => $max_field_order + 1, + ); + + $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->db->sql_query($sql); + $field_id = (int) $this->db->sql_nextid(); + + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); + + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + $lang_name = 'WLM'; + while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) + { + $insert_buffer->insert(array( + 'field_id' => (int) $field_id, + 'lang_id' => (int) $lang_id, + 'lang_name' => $lang_name, + 'lang_explain' => '', + 'lang_default_value' => '', + )); + } + $this->db->sql_freeresult($result); + + $insert_buffer->flush(); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/report_id_auto_increment.php b/phpBB/phpbb/db/migration/data/v320/report_id_auto_increment.php new file mode 100644 index 0000000000..6e81baefb9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/report_id_auto_increment.php @@ -0,0 +1,46 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class report_id_auto_increment extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\default_data_type_ids', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'reports' => array( + 'report_id' => array('ULINT', null, 'auto_increment'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'reports' => array( + 'report_id' => array('ULINT', 0), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/text_reparser.php b/phpBB/phpbb/db/migration/data/v320/text_reparser.php new file mode 100644 index 0000000000..6b8cf93cc9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/text_reparser.php @@ -0,0 +1,121 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v320; + +use phpbb\textreparser\manager; +use phpbb\textreparser\reparser_interface; + +class text_reparser extends \phpbb\db\migration\container_aware_migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v310\contact_admin_form', + '\phpbb\db\migration\data\v320\allowed_schemes_links', + ); + } + + public function effectively_installed() + { + return isset($this->config['reparse_lock']); + } + + public function update_data() + { + return array( + array('config.add', array('reparse_lock', 0, true)), + array('config.add', array('text_reparser.pm_text_cron_interval', 10)), + array('config.add', array('text_reparser.pm_text_last_cron', 0)), + array('config.add', array('text_reparser.poll_option_cron_interval', 10)), + array('config.add', array('text_reparser.poll_option_last_cron', 0)), + array('config.add', array('text_reparser.poll_title_cron_interval', 10)), + array('config.add', array('text_reparser.poll_title_last_cron', 0)), + array('config.add', array('text_reparser.post_text_cron_interval', 10)), + array('config.add', array('text_reparser.post_text_last_cron', 0)), + array('config.add', array('text_reparser.user_signature_cron_interval', 10)), + array('config.add', array('text_reparser.user_signature_last_cron', 0)), + array('custom', array(array($this, 'reparse'))), + ); + } + + public function reparse($resume_data) + { + /** @var manager $reparser_manager */ + $reparser_manager = $this->container->get('text_reparser.manager'); + + if (!is_array($resume_data)) + { + /** @var reparser_interface[] $reparsers */ + $reparsers = $this->container->get('text_reparser_collection'); + + // Initialize all reparsers + foreach ($reparsers as $name => $reparser) + { + $reparser_manager->update_resume_data($name, 1, $reparser->get_max_id(), 100); + } + } + + // Sometimes a cron job is too much + $limit = 100; + $fast_reparsers = array( + 'text_reparser.contact_admin_info', + 'text_reparser.forum_description', + 'text_reparser.forum_rules', + 'text_reparser.group_description', + ); + + if (!is_array($resume_data)) + { + $resume_data = array( + 'reparser' => 0, + 'current' => $this->container->get($fast_reparsers[0])->get_max_id(), + ); + } + + $fast_reparsers_size = count($fast_reparsers); + $processed_records = 0; + while ($processed_records < $limit && $resume_data['reparser'] < $fast_reparsers_size) + { + $reparser = $this->container->get($fast_reparsers[$resume_data['reparser']]); + + // New reparser + if ($resume_data['current'] === 0) + { + $resume_data['current'] = $reparser->get_max_id(); + } + + $start = max(1, $resume_data['current'] + 1 - ($limit - $processed_records)); + $end = max(1, $resume_data['current']); + $reparser->reparse_range($start, $end); + + $processed_records += $end - $start + 1; + $resume_data['current'] = $start - 1; + + if ($start === 1) + { + // Prevent CLI command from running these reparsers again + $reparser_manager->update_resume_data($fast_reparsers[$resume_data['reparser']], 1, 0, $limit); + + $resume_data['reparser']++; + } + } + + if ($resume_data['reparser'] === $fast_reparsers_size) + { + return true; + } + + return $resume_data; + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320.php b/phpBB/phpbb/db/migration/data/v320/v320.php new file mode 100644 index 0000000000..20e741cb8b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320.php @@ -0,0 +1,40 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +use phpbb\db\migration\migration; + +class v320 extends migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\increase_size_of_emotion', + '\phpbb\db\migration\data\v320\cookie_notice', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320a1.php b/phpBB/phpbb/db/migration/data/v320/v320a1.php new file mode 100644 index 0000000000..d7ecb36f90 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320a1.php @@ -0,0 +1,44 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class v320a1 extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-a1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + '\phpbb\db\migration\data\v320\allowed_schemes_links', + '\phpbb\db\migration\data\v320\announce_global_permission', + '\phpbb\db\migration\data\v320\remove_profilefield_wlm', + '\phpbb\db\migration\data\v320\font_awesome_update', + '\phpbb\db\migration\data\v320\icons_alt', + '\phpbb\db\migration\data\v320\log_post_id', + '\phpbb\db\migration\data\v320\remove_outdated_media', + '\phpbb\db\migration\data\v320\notifications_board', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-dev')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320a2.php b/phpBB/phpbb/db/migration/data/v320/v320a2.php new file mode 100644 index 0000000000..ae53a73210 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320a2.php @@ -0,0 +1,38 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class v320a2 extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-a2', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v317rc1', + '\phpbb\db\migration\data\v320\text_reparser', + '\phpbb\db\migration\data\v320\v320a1', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-a2')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320b1.php b/phpBB/phpbb/db/migration/data/v320/v320b1.php new file mode 100644 index 0000000000..5c3a3797cd --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320b1.php @@ -0,0 +1,39 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class v320b1 extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-b1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v317pl1', + '\phpbb\db\migration\data\v320\v320a2', + '\phpbb\db\migration\data\v31x\increase_size_of_dateformat', + '\phpbb\db\migration\data\v320\default_data_type_ids', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-b1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320b2.php b/phpBB/phpbb/db/migration/data/v320/v320b2.php new file mode 100644 index 0000000000..007f7588e6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320b2.php @@ -0,0 +1,40 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +use phpbb\db\migration\migration; + +class v320b2 extends migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-b2', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v318', + '\phpbb\db\migration\data\v320\v320b1', + '\phpbb\db\migration\data\v320\remote_upload_validation', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-b2')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320rc1.php b/phpBB/phpbb/db/migration/data/v320/v320rc1.php new file mode 100644 index 0000000000..a04a2abb19 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320rc1.php @@ -0,0 +1,40 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +use phpbb\db\migration\migration; + +class v320rc1 extends migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v319', + '\phpbb\db\migration\data\v320\report_id_auto_increment', + '\phpbb\db\migration\data\v320\v320b2', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/v320rc2.php b/phpBB/phpbb/db/migration/data/v320/v320rc2.php new file mode 100644 index 0000000000..ec9bb62732 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320rc2.php @@ -0,0 +1,40 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +use phpbb\db\migration\migration; + +class v320rc2 extends migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-RC2', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\remove_duplicate_migrations', + '\phpbb\db\migration\data\v31x\add_log_time_index', + '\phpbb\db\migration\data\v320\add_help_phpbb', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-RC2')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/.htaccess b/phpBB/phpbb/db/migration/data/v32x/.htaccess new file mode 100644 index 0000000000..44242b5418 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/.htaccess @@ -0,0 +1,33 @@ +# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from +# module mod_authz_host to a new module called mod_access_compat (which may be +# disabled) and a new "Require" syntax has been introduced to mod_authz_host. +# We could just conditionally provide both versions, but unfortunately Apache +# does not explicitly tell us its version if the module mod_version is not +# available. In this case, we check for the availability of module +# mod_authz_core (which should be on 2.4 or higher only) as a best guess. +<IfModule mod_version.c> + <IfVersion < 2.4> + <Files "*"> + Order Allow,Deny + Deny from All + </Files> + </IfVersion> + <IfVersion >= 2.4> + <Files "*"> + Require all denied + </Files> + </IfVersion> +</IfModule> +<IfModule !mod_version.c> + <IfModule !mod_authz_core.c> + <Files "*"> + Order Allow,Deny + Deny from All + </Files> + </IfModule> + <IfModule mod_authz_core.c> + <Files "*"> + Require all denied + </Files> + </IfModule> +</IfModule> diff --git a/phpBB/phpbb/db/migration/data/v32x/cookie_notice_p2.php b/phpBB/phpbb/db/migration/data/v32x/cookie_notice_p2.php new file mode 100644 index 0000000000..1a83175705 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/cookie_notice_p2.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class cookie_notice_p2 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320', + ); + } + + public function effectively_installed() + { + return isset($this->config['cookie_notice']); + } + + public function update_data() + { + return array( + array('config.add', array('cookie_notice', '0')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php b/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php new file mode 100644 index 0000000000..b08833fad4 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php @@ -0,0 +1,34 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +use phpbb\db\migration\migration; + +class disable_remote_avatar extends migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v325', + ); + } + + public function update_data() + { + return array( + array('config.update', array('allow_avatar_remote', '0')), + array('config.update', array('allow_avatar_remote_upload', '0')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/email_force_sender.php b/phpBB/phpbb/db/migration/data/v32x/email_force_sender.php new file mode 100644 index 0000000000..5319b7f76e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/email_force_sender.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class email_force_sender extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v321', + ); + } + + public function effectively_installed() + { + return isset($this->config['email_force_sender']); + } + + public function update_data() + { + return array( + array('config.add', array('email_force_sender', '0')), + array('config.remove', array('email_function_name')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php new file mode 100644 index 0000000000..a7b99606f7 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class enable_accurate_pm_button extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v322', + ); + } + + public function effectively_installed() + { + return isset($this->config['enable_accurate_pm_button']); + } + + public function update_data() + { + return array( + array('config.add', array('enable_accurate_pm_button', '1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php b/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php new file mode 100644 index 0000000000..49727e5a62 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php @@ -0,0 +1,31 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class f_list_topics_permission_add extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v321', + ); + } + + public function update_data() + { + return array( + array('permission.add', array('f_list_topics', false, 'f_read')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php new file mode 100644 index 0000000000..16fbdbc77b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php @@ -0,0 +1,54 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class fix_user_styles extends \phpbb\db\migration\migration +{ + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'styles_fix'))), + ); + } + + public function styles_fix() + { + $default_style = (int) $this->config['default_style']; + $enabled_styles = array(); + + // Get enabled styles + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 1'; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $enabled_styles[] = (int) $row['style_id']; + } + $this->db->sql_freeresult($result); + + // Set the default style to users who have an invalid style + $this->sql_query('UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $default_style . ' + WHERE ' . $this->db->sql_in_set('user_style', $enabled_styles, true)); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php new file mode 100644 index 0000000000..afcecf2ef0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class forum_topics_per_page_type extends \phpbb\db\migration\migration +{ + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v323', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_topics_per_page' => array('USINT', 0), + ), + ), + ); + } + +} diff --git a/phpBB/phpbb/db/migration/data/v32x/jquery_update.php b/phpBB/phpbb/db/migration/data/v32x/jquery_update.php new file mode 100644 index 0000000000..6dc58ec638 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/jquery_update.php @@ -0,0 +1,37 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class jquery_update extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return $this->config['load_jquery_url'] === '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'; + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v325rc1', + ); + } + + public function update_data() + { + return array( + array('config.update', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js')), + ); + } + +} diff --git a/phpBB/phpbb/db/migration/data/v32x/load_user_activity_limit.php b/phpBB/phpbb/db/migration/data/v32x/load_user_activity_limit.php new file mode 100644 index 0000000000..71bb6c00bf --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/load_user_activity_limit.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class load_user_activity_limit extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320', + ); + } + + public function effectively_installed() + { + return isset($this->config['load_user_activity_limit']); + } + + public function update_data() + { + return array( + array('config.add', array('load_user_activity_limit', '5000')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php new file mode 100644 index 0000000000..71ee19e3dd --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php @@ -0,0 +1,84 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migration +{ + public function update_data() + { + return [ + ['custom', [[$this, 'update_bbcodes_table']]], + ]; + } + + public function update_bbcodes_table() + { + $sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline, bbcode_match, bbcode_tpl FROM ' . BBCODES_TABLE; + $result = $this->sql_query($sql); + $bbcodes = []; + while ($row = $this->db->sql_fetchrow($result)) + { + $variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without'; + $bbcode_name = strtolower(rtrim($row['bbcode_tag'], '=')); + $bbcodes[$bbcode_name][$variant] = $row; + } + $this->db->sql_freeresult($result); + + foreach ($bbcodes as $bbcode_name => $variants) + { + if (count($variants) === 2) + { + $this->merge_bbcodes($variants['without'], $variants['with']); + } + } + } + + protected function merge_bbcodes(array $without, array $with) + { + try + { + $merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes( + [ + 'usage' => $without['bbcode_match'], + 'template' => $without['bbcode_tpl'] + ], + [ + 'usage' => $with['bbcode_match'], + 'template' => $with['bbcode_tpl'] + ] + ); + } + catch (\Exception $e) + { + // Ignore the pair and move on. The BBCodes would have to be fixed manually + return; + } + + $bbcode_data = [ + 'bbcode_tag' => $without['bbcode_tag'], + 'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'], + 'bbcode_match' => $merged['usage'], + 'bbcode_tpl' => $merged['template'] + ]; + + $sql = 'UPDATE ' . BBCODES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . ' + WHERE bbcode_id = ' . (int) $without['bbcode_id']; + $this->sql_query($sql); + + $sql = 'DELETE FROM ' . BBCODES_TABLE . ' + WHERE bbcode_id = ' . (int) $with['bbcode_id']; + $this->sql_query($sql); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php b/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php new file mode 100644 index 0000000000..7ad396f8e8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class remove_imagick extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v324rc1', + ); + } + + public function update_data() + { + return array( + array('config.remove', array('img_imagick')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php b/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php new file mode 100644 index 0000000000..aeaa3e8979 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php @@ -0,0 +1,42 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class smtp_dynamic_data extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v326rc1', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'set_smtp_dynamic'))), + ); + } + + public function set_smtp_dynamic() + { + $smtp_auth_entries = [ + 'smtp_password', + 'smtp_username', + ]; + $this->sql_query('UPDATE ' . CONFIG_TABLE . ' + SET is_dynamic = 1 + WHERE ' . $this->db->sql_in_set('config_name', $smtp_auth_entries)); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php b/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php new file mode 100644 index 0000000000..433f62ace9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php @@ -0,0 +1,29 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class timezone_p3 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\timezone'); + } + + public function update_data() + { + return array( + array('config.remove', array('board_dst')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php b/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php new file mode 100644 index 0000000000..6e51a01834 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php @@ -0,0 +1,39 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class update_prosilver_bitfield extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v321', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_bbcode_bitfield'))), + ); + } + + public function update_bbcode_bitfield() + { + $sql = 'UPDATE ' . STYLES_TABLE . " + SET bbcode_bitfield = '//g=' + WHERE style_path = 'prosilver'"; + $this->sql_query($sql); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_emoji_permission.php b/phpBB/phpbb/db/migration/data/v32x/user_emoji_permission.php new file mode 100644 index 0000000000..98759c78ee --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_emoji_permission.php @@ -0,0 +1,44 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class user_emoji_permission extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = 'u_emoji'"; + $result = $this->db->sql_query($sql); + $auth_option_id = $this->db->sql_fetchfield('auth_option_id'); + $this->db->sql_freeresult($result); + + return $auth_option_id !== false; + } + + static public function depends_on() + { + return [ + '\phpbb\db\migration\data\v32x\v329rc1', + ]; + } + + public function update_data() + { + return [ + ['permission.add', ['u_emoji']], + ['permission.permission_set', ['REGISTERED', 'u_emoji', 'group']], + ]; + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php new file mode 100644 index 0000000000..93ff31ec6c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php @@ -0,0 +1,46 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_index_p1 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\cookie_notice_p2', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'user_id' => array('user_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'user_id', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php new file mode 100644 index 0000000000..0a471766a0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php @@ -0,0 +1,46 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_index_p2 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p1', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'uid_itm_id' => array('user_id', 'item_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'uid_itm_id', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php new file mode 100644 index 0000000000..1636b3024a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php @@ -0,0 +1,46 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_index_p3 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p2', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_itm_tpe' => array('user_id', 'item_type', 'item_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_itm_tpe', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php new file mode 100644 index 0000000000..e0a107782e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php @@ -0,0 +1,48 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_reduce_column_sizes extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p3', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'user_notifications' => array( + 'item_type' => array('VCHAR:165', ''), + 'method' => array('VCHAR:165', ''), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'user_notifications' => array( + 'item_type' => array('VCHAR:255', ''), + 'method' => array('VCHAR:255', ''), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php new file mode 100644 index 0000000000..50d0642056 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php @@ -0,0 +1,55 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_remove_duplicates extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_temp_index', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'remove_duplicates'))), + ); + } + + public function remove_duplicates() + { + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications'); + + $sql = "SELECT item_type, item_id, user_id, method, MAX(notify) AS notify + FROM {$this->table_prefix}user_notifications + GROUP BY item_type, item_id, user_id, method + HAVING COUNT(item_type) > 1"; + + $result = $this->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // Delete the duplicate entries + $this->sql_query("DELETE FROM {$this->table_prefix}user_notifications + WHERE user_id = {$row['user_id']} + AND item_type = '{$row['item_type']}' + AND method = '{$row['method']}'"); + + // And re-insert as a single one + $insert_buffer->insert($row); + } + $this->db->sql_freeresult($result); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php new file mode 100644 index 0000000000..80256a0e0a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php @@ -0,0 +1,46 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_temp_index extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_reduce_column_sizes', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php new file mode 100644 index 0000000000..51cf90c8a0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -0,0 +1,51 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_unique_index extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_remove_duplicates', + ); + } + + public function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + 'add_unique_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v321.php b/phpBB/phpbb/db/migration/data/v32x/v321.php new file mode 100644 index 0000000000..fdbb5cff19 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v321.php @@ -0,0 +1,38 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v321 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v3111', + '\phpbb\db\migration\data\v32x\v321rc1', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v321rc1.php b/phpBB/phpbb/db/migration/data/v32x/v321rc1.php new file mode 100644 index 0000000000..653a16f327 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v321rc1.php @@ -0,0 +1,39 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v321rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.1-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\v320', + '\phpbb\db\migration\data\v31x\v3111rc1', + '\phpbb\db\migration\data\v32x\load_user_activity_limit', + '\phpbb\db\migration\data\v32x\user_notifications_table_unique_index', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.1-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v322.php b/phpBB/phpbb/db/migration/data/v32x/v322.php new file mode 100644 index 0000000000..7ecbbb3e79 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v322.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v322 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.2', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v3112', + '\phpbb\db\migration\data\v32x\v322rc1', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.2')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v322rc1.php b/phpBB/phpbb/db/migration/data/v32x/v322rc1.php new file mode 100644 index 0000000000..4fd6270132 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v322rc1.php @@ -0,0 +1,41 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v322rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.2-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v321', + '\phpbb\db\migration\data\v32x\fix_user_styles', + '\phpbb\db\migration\data\v32x\update_prosilver_bitfield', + '\phpbb\db\migration\data\v32x\email_force_sender', + '\phpbb\db\migration\data\v32x\f_list_topics_permission_add', + '\phpbb\db\migration\data\v32x\merge_duplicate_bbcodes', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.2-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v323.php b/phpBB/phpbb/db/migration/data/v32x/v323.php new file mode 100644 index 0000000000..1ec28ceb37 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v323.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v323 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.3', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v323rc2', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.3')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v323rc1.php b/phpBB/phpbb/db/migration/data/v32x/v323rc1.php new file mode 100644 index 0000000000..c3fcd1ab0b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v323rc1.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v323rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.3-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v322', + '\phpbb\db\migration\data\v32x\enable_accurate_pm_button', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.3-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v323rc2.php b/phpBB/phpbb/db/migration/data/v32x/v323rc2.php new file mode 100644 index 0000000000..32235ee067 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v323rc2.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v323rc2 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.3-RC2', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v323rc1', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.3-RC2')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v324.php b/phpBB/phpbb/db/migration/data/v32x/v324.php new file mode 100644 index 0000000000..cd7783fdee --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v324.php @@ -0,0 +1,38 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v324 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.4', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v324rc1', + '\phpbb\db\migration\data\v32x\remove_imagick', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.4')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v324rc1.php b/phpBB/phpbb/db/migration/data/v32x/v324rc1.php new file mode 100644 index 0000000000..0221e2621a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v324rc1.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v324rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.4-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v323', + '\phpbb\db\migration\data\v32x\forum_topics_per_page_type', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.4-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v325.php b/phpBB/phpbb/db/migration/data/v32x/v325.php new file mode 100644 index 0000000000..59de4916df --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v325.php @@ -0,0 +1,38 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v325 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.5', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v325rc1', + '\phpbb\db\migration\data\v32x\jquery_update', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.5')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v325rc1.php b/phpBB/phpbb/db/migration/data/v32x/v325rc1.php new file mode 100644 index 0000000000..2d0de0a432 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v325rc1.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v325rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.5-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v324', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.5-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v326.php b/phpBB/phpbb/db/migration/data/v32x/v326.php new file mode 100644 index 0000000000..2d511b9ed8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v326.php @@ -0,0 +1,39 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v326 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.6', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v326rc1', + '\phpbb\db\migration\data\v32x\disable_remote_avatar', + '\phpbb\db\migration\data\v32x\smtp_dynamic_data', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.6')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v326rc1.php b/phpBB/phpbb/db/migration/data/v32x/v326rc1.php new file mode 100644 index 0000000000..092700d3db --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v326rc1.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v326rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.6-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v325', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.6-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v327.php b/phpBB/phpbb/db/migration/data/v32x/v327.php new file mode 100644 index 0000000000..f9ea11f4b9 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v327.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v327 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.7', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v327rc1', + ); + + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.7')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v327rc1.php b/phpBB/phpbb/db/migration/data/v32x/v327rc1.php new file mode 100644 index 0000000000..c8169105af --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v327rc1.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v327rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.7-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v326', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.7-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v328.php b/phpBB/phpbb/db/migration/data/v32x/v328.php new file mode 100644 index 0000000000..28ff2c7033 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v328.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v328 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.8', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v328rc1', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.8')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v328rc1.php b/phpBB/phpbb/db/migration/data/v32x/v328rc1.php new file mode 100644 index 0000000000..fa43cf33a7 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v328rc1.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v328rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.8-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\timezone_p3', + '\phpbb\db\migration\data\v32x\v327', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.8-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v329.php b/phpBB/phpbb/db/migration/data/v32x/v329.php new file mode 100644 index 0000000000..e88e264aef --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v329.php @@ -0,0 +1,37 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v329 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.9', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v329rc1', + '\phpbb\db\migration\data\v32x\user_emoji_permission', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.9')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/v329rc1.php b/phpBB/phpbb/db/migration/data/v32x/v329rc1.php new file mode 100644 index 0000000000..271bf62859 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v329rc1.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v329rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.9-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v328', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.9-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/migration.php b/phpBB/phpbb/db/migration/migration.php index 5f120333e1..4e218344f4 100644 --- a/phpBB/phpbb/db/migration/migration.php +++ b/phpBB/phpbb/db/migration/migration.php @@ -20,7 +20,7 @@ namespace phpbb\db\migration; * in a subclass. This class provides various utility methods to simplify editing * a phpBB. */ -abstract class migration +abstract class migration implements migration_interface { /** @var \phpbb\config\config */ protected $config; @@ -28,7 +28,7 @@ abstract class migration /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\db\tools */ + /** @var \phpbb\db\tools\tools_interface */ protected $db_tools; /** @var string */ @@ -51,12 +51,12 @@ abstract class migration * * @param \phpbb\config\config $config * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\db\tools $db_tools + * @param \phpbb\db\tools\tools_interface $db_tools * @param string $phpbb_root_path * @param string $php_ext * @param string $table_prefix */ - public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix) + public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix) { $this->config = $config; $this->db = $db; @@ -70,9 +70,7 @@ abstract class migration } /** - * Defines other migrations to be applied first - * - * @return array An array of migration class names + * {@inheritdoc} */ static public function depends_on() { @@ -80,14 +78,7 @@ abstract class migration } /** - * Allows you to check if the migration is effectively installed (entirely optional) - * - * This is checked when a migration is installed. If true is returned, the migration will be set as - * installed without performing the database changes. - * This function is intended to help moving to migrations from a previous database updater, where some - * migrations may have been installed already even though they are not yet listed in the migrations table. - * - * @return bool True if this migration is installed, False if this migration is not installed (checked on install) + * {@inheritdoc} */ public function effectively_installed() { @@ -95,9 +86,7 @@ abstract class migration } /** - * Updates the database schema by providing a set of change instructions - * - * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) + * {@inheritdoc} */ public function update_schema() { @@ -105,9 +94,7 @@ abstract class migration } /** - * Reverts the database schema by providing a set of change instructions - * - * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) + * {@inheritdoc} */ public function revert_schema() { @@ -115,9 +102,7 @@ abstract class migration } /** - * Updates data by returning a list of instructions to be executed - * - * @return array Array of data update instructions + * {@inheritdoc} */ public function update_data() { @@ -125,12 +110,7 @@ abstract class migration } /** - * Reverts data by returning a list of instructions to be executed - * - * @return array Array of data instructions that will be performed on revert - * NOTE: calls to tools (such as config.add) are automatically reverted when - * possible, so you should not attempt to revert those, this is mostly for - * otherwise unrevertable calls (custom functions for example) + * {@inheritdoc} */ public function revert_data() { diff --git a/phpBB/phpbb/db/migration/migration_interface.php b/phpBB/phpbb/db/migration/migration_interface.php new file mode 100644 index 0000000000..2aba5ec608 --- /dev/null +++ b/phpBB/phpbb/db/migration/migration_interface.php @@ -0,0 +1,70 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration; + +/** + * Base class interface for database migrations + */ +interface migration_interface +{ + /** + * Defines other migrations to be applied first + * + * @return array An array of migration class names + */ + static public function depends_on(); + + /** + * Allows you to check if the migration is effectively installed (entirely optional) + * + * This is checked when a migration is installed. If true is returned, the migration will be set as + * installed without performing the database changes. + * This function is intended to help moving to migrations from a previous database updater, where some + * migrations may have been installed already even though they are not yet listed in the migrations table. + * + * @return bool True if this migration is installed, False if this migration is not installed (checked on install) + */ + public function effectively_installed(); + + /** + * Updates the database schema by providing a set of change instructions + * + * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) + */ + public function update_schema(); + + /** + * Reverts the database schema by providing a set of change instructions + * + * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) + */ + public function revert_schema(); + + /** + * Updates data by returning a list of instructions to be executed + * + * @return array Array of data update instructions + */ + public function update_data(); + + /** + * Reverts data by returning a list of instructions to be executed + * + * @return array Array of data instructions that will be performed on revert + * NOTE: calls to tools (such as config.add) are automatically reverted when + * possible, so you should not attempt to revert those, this is mostly for + * otherwise unrevertable calls (custom functions for example) + */ + public function revert_data(); +} diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php index b20ca874be..bc542a8fed 100644 --- a/phpBB/phpbb/db/migration/profilefield_base_migration.php +++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php @@ -238,6 +238,7 @@ abstract class profilefield_base_migration extends container_aware_migration if ($profile_row === null) { + /* @var $manager \phpbb\profilefields\manager */ $manager = $this->container->get('profilefields.manager'); $profile_row = $manager->build_insert_sql_array(array()); } diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 91d8307d91..c579e25824 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -24,7 +24,7 @@ class schema_generator /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\db\tools */ + /** @var \phpbb\db\tools\tools_interface */ protected $db_tools; /** @var array */ @@ -48,7 +48,7 @@ class schema_generator /** * Constructor */ - public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix) + public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix) { $this->config = $config; $this->db = $db; @@ -77,8 +77,15 @@ class schema_generator $check_dependencies = true; while (!empty($migrations)) { - foreach ($migrations as $migration_class) + foreach ($migrations as $key => $migration_class) { + // Unset classes that are not a valid migration + if (\phpbb\db\migrator::is_migration($migration_class) === false) + { + unset($migrations[$key]); + continue; + } + $open_dependencies = array_diff($migration_class::depends_on(), $tree); if (empty($open_dependencies)) diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php index 33aa8ff026..a351c4858e 100644 --- a/phpBB/phpbb/db/migration/tool/config.php +++ b/phpBB/phpbb/db/migration/tool/config.php @@ -134,7 +134,7 @@ class config implements \phpbb\db\migration\tool\tool_interface case 'remove': $call = 'add'; - if (sizeof($arguments) == 1) + if (count($arguments) == 1) { $arguments[] = ''; } diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php index 54b45f6f6d..5fe9a25b70 100644 --- a/phpBB/phpbb/db/migration/tool/config_text.php +++ b/phpBB/phpbb/db/migration/tool/config_text.php @@ -110,7 +110,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface case 'remove': $call = 'add'; - if (sizeof($arguments) == 1) + if (count($arguments) == 1) { $arguments[] = ''; } diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 7ea7d1dac1..e5133c8152 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -13,6 +13,8 @@ namespace phpbb\db\migration\tool; +use phpbb\module\exception\module_exception; + /** * Migration module management tool */ @@ -27,6 +29,9 @@ class module implements \phpbb\db\migration\tool\tool_interface /** @var \phpbb\user */ protected $user; + /** @var \phpbb\module\module_manager */ + protected $module_manager; + /** @var string */ protected $phpbb_root_path; @@ -45,15 +50,17 @@ class module implements \phpbb\db\migration\tool\tool_interface * @param \phpbb\db\driver\driver_interface $db * @param \phpbb\cache\service $cache * @param \phpbb\user $user + * @param \phpbb\module\module_manager $module_manager * @param string $phpbb_root_path * @param string $php_ext * @param string $modules_table */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, $phpbb_root_path, $php_ext, $modules_table) + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, \phpbb\module\module_manager $module_manager, $phpbb_root_path, $php_ext, $modules_table) { $this->db = $db; $this->cache = $cache; $this->user = $user; + $this->module_manager = $module_manager; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->modules_table = $modules_table; @@ -77,9 +84,12 @@ class module implements \phpbb\db\migration\tool\tool_interface * Use false to ignore the parent check and check class wide. * @param int|string $module The module_id|module_langname you would like to * check for to see if it exists - * @return bool true/false if module exists + * @param bool $lazy Checks lazily if the module exists. Returns true if it exists in at + * least one given parent. + * @return bool true if module exists in *all* given parents, false if not in any given parent; + * true if ignoring parent check and module exists class wide, false if not found at all. */ - public function exists($class, $parent, $module) + public function exists($class, $parent, $module, $lazy = false) { // the main root directory should return true if (!$module) @@ -87,33 +97,48 @@ class module implements \phpbb\db\migration\tool\tool_interface return true; } - $parent_sql = ''; + $parent_sqls = []; if ($parent !== false) { - $parent = $this->get_parent_module_id($parent, $module, false); - if ($parent === false) + $parents = $this->get_parent_module_id($parent, $module, false); + if ($parents === false) { return false; } - $parent_sql = 'AND parent_id = ' . (int) $parent; + foreach ((array) $parents as $parent_id) + { + $parent_sqls[] = 'AND parent_id = ' . (int) $parent_id; + } + } + else + { + $parent_sqls[] = ''; } - $sql = 'SELECT module_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - $parent_sql - AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'"); - $result = $this->db->sql_query($sql); - $module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - - if ($module_id) + foreach ($parent_sqls as $parent_sql) { - return true; + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " + WHERE module_class = '" . $this->db->sql_escape($class) . "' + $parent_sql + AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'"); + $result = $this->db->sql_query($sql); + $module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!$lazy && !$module_id) + { + return false; + } + if ($lazy && $module_id) + { + return true; + } } - return false; + // Returns true, if modules exist in all parents and false otherwise + return !$lazy; } /** @@ -157,13 +182,15 @@ class module implements \phpbb\db\migration\tool\tool_interface */ public function add($class, $parent = 0, $data = array()) { + global $user, $phpbb_log; + // allow sending the name as a string in $data to create a category if (!is_array($data)) { $data = array('module_langname' => $data); } - $parent = $data['parent_id'] = $this->get_parent_module_id($parent, $data); + $parents = (array) $this->get_parent_module_id($parent, $data); if (!isset($data['module_langname'])) { @@ -171,7 +198,6 @@ class module implements \phpbb\db\migration\tool\tool_interface $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; $module = $this->get_module_info($class, $basename); - $result = ''; foreach ($module['modes'] as $mode => $module_info) { if (!isset($data['modes']) || in_array($mode, $data['modes'])) @@ -187,106 +213,135 @@ class module implements \phpbb\db\migration\tool\tool_interface ); // Run the "manual" way with the data we've collected. - $this->add($class, $parent, $new_module); + foreach ($parents as $parent) + { + $this->add($class, $parent, $new_module); + } } } return; } - // The "manual" way - if (!$this->exists($class, false, $parent)) + foreach ($parents as $parent) { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent); - } + $data['parent_id'] = $parent; - if ($this->exists($class, $parent, $data['module_langname'])) - { - throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']); - } + // The "manual" way + if (!$this->exists($class, false, $parent)) + { + throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent); + } - if (!class_exists('acp_modules')) - { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); - $this->user->add_lang('acp/modules'); - } - $acp_modules = new \acp_modules(); - - $module_data = array( - 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, - 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, - 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', - 'module_class' => $class, - 'parent_id' => (int) $parent, - 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', - 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', - 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', - ); - $result = $acp_modules->update_module_data($module_data, true); - - // update_module_data can either return a string or an empty array... - if (is_string($result)) - { - // Error - throw new \phpbb\db\migration\exception('MODULE_ERROR', $result); - } - else - { - // Success - $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); - add_log('admin', 'LOG_MODULE_ADD', $module_log_name); + if ($this->exists($class, $parent, $data['module_langname'])) + { + throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']); + } - // Move the module if requested above/below an existing one - if (isset($data['before']) && $data['before']) + $module_data = array( + 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, + 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, + 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', + 'module_class' => $class, + 'parent_id' => (int) $parent, + 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', + 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', + 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', + ); + + try { - $sql = 'SELECT left_id + $this->module_manager->update_module_data($module_data); + + // Success + $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); + $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name)); + + // Move the module if requested above/below an existing one + if (isset($data['before']) && $data['before']) + { + $before_mode = $before_langname = ''; + if (is_array($data['before'])) + { + // Restore legacy-legacy behaviour from phpBB 3.0 + list($before_mode, $before_langname) = $data['before']; + } + else + { + // Legacy behaviour from phpBB 3.1+ + $before_langname = $data['before']; + } + + $sql = 'SELECT left_id FROM ' . $this->modules_table . " WHERE module_class = '" . $this->db->sql_escape($class) . "' AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($data['before']) . "'"; - $this->db->sql_query($sql); - $to_left = (int) $this->db->sql_fetchfield('left_id'); + AND module_langname = '" . $this->db->sql_escape($before_langname) . "'" + . (($before_mode) ? " AND module_mode = '" . $this->db->sql_escape($before_mode) . "'" : ''); + $result = $this->db->sql_query($sql); + $to_left = (int) $this->db->sql_fetchfield('left_id'); + $this->db->sql_freeresult($result); - $sql = 'UPDATE ' . $this->modules_table . " + $sql = 'UPDATE ' . $this->modules_table . " SET left_id = left_id + 2, right_id = right_id + 2 WHERE module_class = '" . $this->db->sql_escape($class) . "' AND left_id >= $to_left AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); + $this->db->sql_query($sql); - $sql = 'UPDATE ' . $this->modules_table . " + $sql = 'UPDATE ' . $this->modules_table . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " WHERE module_class = '" . $this->db->sql_escape($class) . "' AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - else if (isset($data['after']) && $data['after']) - { - $sql = 'SELECT right_id + $this->db->sql_query($sql); + } + else if (isset($data['after']) && $data['after']) + { + $after_mode = $after_langname = ''; + if (is_array($data['after'])) + { + // Restore legacy-legacy behaviour from phpBB 3.0 + list($after_mode, $after_langname) = $data['after']; + } + else + { + // Legacy behaviour from phpBB 3.1+ + $after_langname = $data['after']; + } + + $sql = 'SELECT right_id FROM ' . $this->modules_table . " WHERE module_class = '" . $this->db->sql_escape($class) . "' AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($data['after']) . "'"; - $this->db->sql_query($sql); - $to_right = (int) $this->db->sql_fetchfield('right_id'); + AND module_langname = '" . $this->db->sql_escape($after_langname) . "'" + . (($after_mode) ? " AND module_mode = '" . $this->db->sql_escape($after_mode) . "'" : ''); + $result = $this->db->sql_query($sql); + $to_right = (int) $this->db->sql_fetchfield('right_id'); + $this->db->sql_freeresult($result); - $sql = 'UPDATE ' . $this->modules_table . " + $sql = 'UPDATE ' . $this->modules_table . " SET left_id = left_id + 2, right_id = right_id + 2 WHERE module_class = '" . $this->db->sql_escape($class) . "' AND left_id >= $to_right AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); + $this->db->sql_query($sql); - $sql = 'UPDATE ' . $this->modules_table . ' + $sql = 'UPDATE ' . $this->modules_table . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " WHERE module_class = '" . $this->db->sql_escape($class) . "' AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); + $this->db->sql_query($sql); + } + } + catch (module_exception $e) + { + // Error + throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage()); } } // Clear the Modules Cache - $this->cache->destroy("_modules_$class"); + $this->module_manager->remove_cache_file($class); } /** @@ -333,7 +388,7 @@ class module implements \phpbb\db\migration\tool\tool_interface } else { - if (!$this->exists($class, $parent, $module)) + if (!$this->exists($class, $parent, $module, true)) { return; } @@ -341,8 +396,8 @@ class module implements \phpbb\db\migration\tool\tool_interface $parent_sql = ''; if ($parent !== false) { - $parent = $this->get_parent_module_id($parent, $module); - $parent_sql = 'AND parent_id = ' . (int) $parent; + $parents = (array) $this->get_parent_module_id($parent, $module); + $parent_sql = 'AND ' . $this->db->sql_in_set('parent_id', $parents); } $module_ids = array(); @@ -365,24 +420,12 @@ class module implements \phpbb\db\migration\tool\tool_interface $module_ids[] = (int) $module; } - if (!class_exists('acp_modules')) - { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); - $this->user->add_lang('acp/modules'); - } - $acp_modules = new \acp_modules(); - $acp_modules->module_class = $class; - foreach ($module_ids as $module_id) { - $result = $acp_modules->delete_module($module_id); - if (!empty($result)) - { - return; - } + $this->module_manager->delete_module($module_id, $class); } - $this->cache->destroy("_modules_$class"); + $this->module_manager->remove_cache_file($class); } } @@ -427,13 +470,7 @@ class module implements \phpbb\db\migration\tool\tool_interface */ protected function get_module_info($class, $basename) { - if (!class_exists('acp_modules')) - { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); - $this->user->add_lang('acp/modules'); - } - $acp_modules = new \acp_modules(); - $module = $acp_modules->get_module_infos($basename, $class, true); + $module = $this->module_manager->get_module_infos($class, $basename, true); if (empty($module)) { @@ -474,23 +511,14 @@ class module implements \phpbb\db\migration\tool\tool_interface * @param string|int $parent_id The parent module_id|module_langname * @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding * @param bool $throw_exception The flag indicating if exception should be thrown on error - * @return mixed The int parent module_id or false + * @return mixed The int parent module_id, an array of int parent module_id values or false * @throws \phpbb\db\migration\exception */ public function get_parent_module_id($parent_id, $data = '', $throw_exception = true) { - // Initialize exception object placeholder - $exception = false; - // Allow '' to be sent as 0 $parent_id = $parent_id ?: 0; - // If automatic adding is in action, convert array back to string to simplify things - if (is_array($data) && sizeof($data) == 1) - { - $data = $data['module_langname']; - } - if (!is_numeric($parent_id)) { // Refresh the $module_categories array @@ -499,65 +527,30 @@ class module implements \phpbb\db\migration\tool\tool_interface // Search for the parent module_langname $ids = array_keys($this->module_categories, $parent_id); - switch (sizeof($ids)) + switch (count($ids)) { // No parent with the given module_langname exist case 0: - $exception = new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); + if ($throw_exception) + { + throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); + } + + return false; break; // Return the module id case 1: - $parent_id = (int) $ids[0]; + return (int) $ids[0]; break; - // Several modules with the given module_langname were found - // Try to determine the parent_id by the neighbour module parent default: - if (is_array($data) && (isset($data['before']) || isset($data['after']))) - { - $neighbour_module_langname = isset($data['before']) ? $data['before'] : $data['after']; - $sql = 'SELECT parent_id - FROM ' . $this->modules_table . " - WHERE module_langname = '" . $this->db->sql_escape($neighbour_module_langname) . "' - AND " . $this->db->sql_in_set('parent_id', $ids); - $result = $this->db->sql_query($sql); - $parent_id = (int) $this->db->sql_fetchfield('parent_id'); - if (!$parent_id) - { - $exception = new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']); - } - } - else if (!empty($data) && !is_array($data)) - { - // The module_langname is set, checking for the module existance - // As more than 1 parents were found already, there's no way for null parent_id here - $sql = 'SELECT m2.module_id as module_parent_id - FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2 - WHERE " . ((is_numeric($data)) ? 'm1.module_id = ' . (int) $data : "m1.module_langname = '" . $this->db->sql_escape($data)) . "' - AND m2.module_id = m1.parent_id - AND " . $this->db->sql_in_set('m2.module_id', $ids); - $result = $this->db->sql_query($sql); - $parent_id = (int) $this->db->sql_fetchfield('module_parent_id'); - } - else - { - //Unable to get the parent module id, throwing an exception - $exception = new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id); - } + // This represents the old behaviour of phpBB 3.0 + return $ids; break; } } - if ($exception !== false) - { - if ($throw_exception) - { - throw $exception; - } - return false; - } - return $parent_id; } } diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index 9688420025..4b53aa32a7 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -442,7 +442,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface } ); - if (sizeof($auth_option)) + if (count($auth_option)) { return $this->permission_set($role_name, $auth_option, 'role', $has_permission); } |