From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- phpBB/install/database_update.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6e99fd56a0..63a949762b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -91,7 +91,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true); require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/db/db_tools.' . $phpEx); @@ -121,7 +120,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function @@ -2601,10 +2600,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) -- cgit v1.2.1 From 195014867ae84fe04ec01c913e38bf1d435590f7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 11:25:22 +0100 Subject: [ticket/11183] Remove $load_extensions and weird dl() calls PHPBB3-11183 --- phpBB/install/database_update.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 527108af08..dcdd17cbc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -73,17 +73,6 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) die("Please read: INSTALL.html before attempting to update."); } -// Load Extensions -if (!empty($load_extensions) && function_exists('dl')) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); @@ -2716,10 +2705,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2752,7 +2741,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); -- cgit v1.2.1 From f48709f5bb8fb1b916d308e3b4bb06bc96d08611 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 19 Oct 2012 19:53:29 -0400 Subject: [feature/compiled-dic] Compile the DI Container into a cached class PHPBB3-11152 --- phpBB/install/database_update.php | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 527108af08..65c72ad635 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -109,20 +109,28 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); -$loader->load('services.yml'); - -// We must include the DI processor class files because the class loader -// is not yet set up -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); - // Setup class loader first -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); + +// Set up container +$phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $phpbb_root_path, + $phpEx +); + +$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); +$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From f9f03435f0681ab1aba1ff23d84fb4101be37e46 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 17:03:06 -0400 Subject: [feature/compiled-dic] Move this to the other PR PHPBB3-11152 --- phpBB/install/database_update.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 65c72ad635..3d296545b4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,9 +121,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx -- cgit v1.2.1 From cb2725dd5a04118de8628e10f940e926f4fa8fa1 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:09:43 -0400 Subject: [feature/compiled-dic] Fix cron task loading We cannot use container tags at run time if we are using a cached, compiled container object (i.e. phpbb_cache_container) so we have to load them beforehand. PHPBB3-11152 --- phpBB/install/database_update.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3d296545b4..1734272486 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); -- cgit v1.2.1 From 897e8f2e8361839a92acae7e77225ef212e44647 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 9 Nov 2012 23:00:44 +0100 Subject: [ticket/11152] Move container functions to a separate function file PHPBB3-11152 --- phpBB/install/database_update.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1734272486..a5c4e2acd3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -88,6 +88,7 @@ if (!empty($load_extensions) && function_exists('dl')) require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); @@ -2723,10 +2724,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2759,7 +2760,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); -- cgit v1.2.1 From bd37f7f6c04780819dfa8f81b2d761b91859fd67 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:45:02 -0600 Subject: [ticket/11189] Replace DEBUG_EXTRA with DEBUG PHPBB3-11189 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index dcdd17cbc0..899394cd08 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -620,7 +620,7 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "
\n{$sql}\n
"; } -- cgit v1.2.1 From 231d743ba9966e8304e0dd226ebf5eb7fb3b70d8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:34:27 +0100 Subject: [ticket/11152] Change phpbb_di_pass_cron to generic phpbb_di_pass_collection PHPBB3-11152 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a5c4e2acd3..bc45b27cdc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 8851b797fbf0f1b4120aa4d3ae713711e01ef98f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:35:52 +0100 Subject: [ticket/11152] Create separate function for debug-dependent container PHPBB3-11152 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bc45b27cdc..add59b3c85 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -117,7 +117,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_compiled_container( +$phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), -- cgit v1.2.1 From 3e4d3761fdec878758e43779eab124816596c8aa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Nov 2012 14:18:11 +0100 Subject: [ticket/11152] Rename collection to collection_pass PHPBB3-11152 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index add59b3c85..1940daf334 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 844770d223eca4fe509a00e6e979be7cb58eadd5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Nov 2012 17:43:12 +0100 Subject: [ticket/11152] Remove old container processor calls PHPBB3-11152 --- phpBB/install/database_update.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1940daf334..0121ccab1e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -142,13 +142,6 @@ $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From d2a051cdd4269fd5749bdd4e7619fc5176a510a8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 11 Nov 2012 18:39:24 +0100 Subject: [ticket/11193] Instantiate a single collection_pass for all collections PHPBB3-11193 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 27cc4951a9..297802c210 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -112,7 +112,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From dd1f8a0e554cc7c7fd975089cfd01acc88c656a6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 11 Nov 2012 19:41:45 -0500 Subject: [feature/controller-new] Call pass to subscribe the Kernel event listener PHPBB3-10864 --- phpBB/install/database_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 297802c210..b8f5021dfd 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -113,6 +113,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 4b6d538b062a56f55ba221ac8437b4bfc712a475 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 13 Nov 2012 09:28:56 -0500 Subject: [feature/controller] Rename kernel pass class properly PHPBB3-10864 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b8f5021dfd..377e38c423 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -113,7 +113,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel(), + new phpbb_di_pass_kernel_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 80da19ca7c12feb2996fd9d64dbdc8cb5c3cd2d9 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 7 Nov 2012 09:13:16 +0000 Subject: [ticket/10601] Database updating code This is what is needed to update the database to comply with these code changes PHPBB3-10601 --- phpBB/install/database_update.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 377e38c423..7b20404cf2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2749,6 +2749,33 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_url', ''); $config->set('site_home_text', ''); } + + + // ticket/10601: Make inbox default. Add basename to ucp's pm category + // Check if this was already applied + $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + FROM ' . MODULES_TABLE . ' + WHERE + module_basename = \'ucp_pm\' + ORDER BY module_id'; + $result = $db->sql_query_limit($sql, 1); + + if ($row = $db->sql_fetchrow($result)) + { + // Checking if this is not a category + if ($row['left_id'] === $row['right_id'] - 1) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_basename = \'ucp_pm\' + WHERE module_id = ' . (int)$row['parent_id']; + + _sql($sql, $errored, $error_ary); + + } + } + $db->sql_freeresult($result); break; } -- cgit v1.2.1 From 85ebbbaec471ea64f22543e006f8c160b02d503f Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 7 Nov 2012 22:26:54 +0000 Subject: [ticket/10601] Database updating code v2 Added the space after the (int) as requested PHPBB3-10601 --- phpBB/install/database_update.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7b20404cf2..620af92173 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2753,29 +2753,29 @@ function change_database_data(&$no_updates, $version) // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied - $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id - FROM ' . MODULES_TABLE . ' - WHERE - module_basename = \'ucp_pm\' - ORDER BY module_id'; - $result = $db->sql_query_limit($sql, 1); + $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + FROM ' . MODULES_TABLE . ' + WHERE + module_basename = \'ucp_pm\' + ORDER BY module_id'; + $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) + { + // Checking if this is not a category + if ($row['left_id'] === $row['right_id'] - 1) { - // Checking if this is not a category - if ($row['left_id'] === $row['right_id'] - 1) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_basename = \'ucp_pm\' - WHERE module_id = ' . (int)$row['parent_id']; - - _sql($sql, $errored, $error_ary); + // This update is still not applied. Applying it - } + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_basename = \'ucp_pm\' + WHERE module_id = ' . (int) $row['parent_id']; + + _sql($sql, $errored, $error_ary); + } - $db->sql_freeresult($result); + } + $db->sql_freeresult($result); break; } -- cgit v1.2.1 From 1f9eaa1c56ec909bde82e1d7ad86079cd23f46bc Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Fri, 9 Nov 2012 08:51:18 +0000 Subject: [ticket/10601] Cosmetic code changes - Removed the double line before the addition - Moved the condition of the WHERE so that both are in the same line - Removed TABs from the black lines - Used double quotes instead of escaped single quotes. PHPBB3-10601 --- phpBB/install/database_update.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 620af92173..1dae3e566b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2749,14 +2749,12 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_url', ''); $config->set('site_home_text', ''); } - - + // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id FROM ' . MODULES_TABLE . ' - WHERE - module_basename = \'ucp_pm\' + WHERE module_basename = "ucp_pm" ORDER BY module_id'; $result = $db->sql_query_limit($sql, 1); @@ -2766,13 +2764,13 @@ function change_database_data(&$no_updates, $version) if ($row['left_id'] === $row['right_id'] - 1) { // This update is still not applied. Applying it - + $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_basename = \'ucp_pm\' WHERE module_id = ' . (int) $row['parent_id']; - + _sql($sql, $errored, $error_ary); - + } } $db->sql_freeresult($result); -- cgit v1.2.1 From a4cc07617726bffd4c64cdebaa2e20a463990c5d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 28 Nov 2012 19:36:13 +0000 Subject: [ticket/10601] Requested code changes - Renamed the comment to PHPBB3-10601 - Removed backslashes - Traded double quotes into single quotes inside. PHPBB3-10601 --- phpBB/install/database_update.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1dae3e566b..eed484dfae 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2753,9 +2753,9 @@ function change_database_data(&$no_updates, $version) // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id - FROM ' . MODULES_TABLE . ' - WHERE module_basename = "ucp_pm" - ORDER BY module_id'; + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_pm' + ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) @@ -2765,9 +2765,9 @@ function change_database_data(&$no_updates, $version) { // This update is still not applied. Applying it - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_basename = \'ucp_pm\' - WHERE module_id = ' . (int) $row['parent_id']; + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['parent_id']; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From a0d5c52eb6e8ef3a6bb44cff60b364d3a3a5bf3e Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 09:44:51 +0000 Subject: [ticket/10601] New approach in the update algorithm - New approach in the database update algorithm PHPBB3-10601 --- phpBB/install/database_update.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index eed484dfae..f3136690a2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2750,28 +2750,25 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } - // ticket/10601: Make inbox default. Add basename to ucp's pm category - // Check if this was already applied - $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category + + // Get the category wanted while checking, at the same time, if this has already been applied + $sql = 'SELECT module_id, module_basename FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_pm' + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM' ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { - // Checking if this is not a category - if ($row['left_id'] === $row['right_id'] - 1) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['parent_id']; + // This update is still not applied. Applying it - _sql($sql, $errored, $error_ary); + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; - } + _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); -- cgit v1.2.1 From 314462d8352a6b5ea1fd27ce1bb21cb0a8fb1310 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 22:36:01 +0100 Subject: [ticket/10184] Disable receiving pms for bots by default PHPBB3-10184 --- phpBB/install/database_update.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 399ad3429a..8e23434b5b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2171,6 +2171,12 @@ function change_database_data(&$no_updates, $version) } } + // Disable receiving pms for bots + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE user_type = ' . USER_IGNORE; + $db->sql_query($sql); + $no_updates = false; break; } -- cgit v1.2.1 From ad2d560f3f6ab0232728392b2c1c946f2b07902d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Nov 2012 14:32:31 +0100 Subject: [ticket/10184] Query bots table to get the user_ids of the bots PHPBB3-10184 --- phpBB/install/database_update.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8e23434b5b..983b1b46c4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2172,10 +2172,24 @@ function change_database_data(&$no_updates, $version) } // Disable receiving pms for bots - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE user_type = ' . USER_IGNORE; - $db->sql_query($sql); + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); + _sql($sql, $errored, $error_ary); + } $no_updates = false; break; -- cgit v1.2.1 From 1ce06711811561d2e3fa3c6ba2aeac4ebffa6581 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 10:05:20 +0000 Subject: [ticket/10601] The ORDER BY is only taking space there PHPBB3-10601 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f3136690a2..ae6e3bd9cf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2757,7 +2757,7 @@ function change_database_data(&$no_updates, $version) FROM ' . MODULES_TABLE . " WHERE module_basename <> 'ucp_pm' AND module_langname='UCP_PM' - ORDER BY module_id"; + "; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From 4103c99a8676653a868014a6f58a76e8986bd5ed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 1 Mar 2012 16:15:11 +0100 Subject: [ticket/10679] Add new permission for changing profile field information The setting is copied from "Can use signature" PHPBB3-10679 --- phpBB/install/database_update.php | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e966756337..f0a16844e9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2731,8 +2731,6 @@ function change_database_data(&$no_updates, $version) $config->set('display_last_subject', '1'); } - $no_updates = false; - if (!isset($config['assets_version'])) { $config->set('assets_version', '1'); @@ -2771,7 +2769,7 @@ function change_database_data(&$no_updates, $version) } // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category - + // Get the category wanted while checking, at the same time, if this has already been applied $sql = 'SELECT module_id, module_basename FROM ' . MODULES_TABLE . " @@ -2788,10 +2786,52 @@ function change_database_data(&$no_updates, $version) SET module_basename = 'ucp_pm' WHERE module_id = " . (int) $row['module_id']; - _sql($sql, $errored, $error_ary); + _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); + // Add new permission u_chgprofileinfo and duplicate settings from u_sig + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_chgprofileinfo'])) + { + $auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['u_sig']; + $new_id = $auth_admin->acl_options['id']['u_chgprofileinfo']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + + $no_updates = false; + break; } } -- cgit v1.2.1 From 2f490293e4b8d08d6c1008ef5ea324ae259d9993 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Dec 2012 16:33:12 +0100 Subject: [ticket/10679] Use module_auth to limit access to the module PHPBB3-10679 --- phpBB/install/database_update.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f0a16844e9..95fd1ca2c2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2830,6 +2830,14 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_clear_prefetch(); } + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'profile' + AND module_mode = 'profile_info'"; + _sql($sql, $errored, $error_ary); + $no_updates = false; break; -- cgit v1.2.1 From c23d2457e9be616bfa83aebc5e743130b6c69624 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 12:50:21 +0100 Subject: [ticket/10679] Update module basename, we added the xcp_ prefix in 3.1 PHPBB3-10679 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 95fd1ca2c2..30592b995d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2834,7 +2834,7 @@ function change_database_data(&$no_updates, $version) $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_u_chgprofileinfo' WHERE module_class = 'ucp' - AND module_basename = 'profile' + AND module_basename = 'ucp_profile' AND module_mode = 'profile_info'"; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From 4980d8b01150593175274dad45890544f56075d6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 2 Sep 2012 23:44:13 -0400 Subject: [ticket/11088] Move style, extension and language pack management to customise Instead of being separated, these related ACP modules are now grouped intuitively. PHPBB3-11088 --- phpBB/install/database_update.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 30592b995d..d276cdbc57 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2489,6 +2489,20 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), + 'lang_management' => array( + 'base' => 'acp_language', + 'class' => 'acp', + 'title' => 'ACL_LANGUAGE_PACKS', + 'auth' => 'acl_a_language', + 'cat' => 'ACL_LANGUAGE', + ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', -- cgit v1.2.1 From e58c6536f0407ec5f82c634c058270c4e627d03d Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 18:03:35 -0400 Subject: [ticket/11088] Untested progress for update script PHPBB3-11088 --- phpBB/install/database_update.php | 55 +++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d276cdbc57..73efa3f7f6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,6 +2459,19 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } + // Create new Customise ACP tab + $module_manager = new acp_modules(); + $module_manager->update_module_data(array( + 'parent_id' => 0, + 'module_enabled' => 1, + 'module_display' => 1, + 'module_basename' => ''. + 'module_class' => 'acp', + 'module_mode' => '', + 'module_auth' => '', + 'module_langname' => 'ACP_CAT_CUSTOMISE', + )); + // Install modules $modules_to_install = array( 'position' => array( @@ -2489,20 +2502,6 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - 'lang_management' => array( - 'base' => 'acp_language', - 'class' => 'acp', - 'title' => 'ACL_LANGUAGE_PACKS', - 'auth' => 'acl_a_language', - 'cat' => 'ACL_LANGUAGE', - ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', @@ -2510,6 +2509,13 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), ); _add_modules($modules_to_install); @@ -2518,6 +2524,27 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language' OR module_langname = 'styles'"; + $result = $db->sql_query($sql); + $modules_to_move = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + // Next, selec the ID of the new parent module + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; + $result = $db->sql_query($sql); + $customise_category_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + // Now perform the move + foreach ($modules_to_move as $module_id) + { + $module_manager->move_module($module_id, $customise_category_id); + } + // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' -- cgit v1.2.1 From 72d1a210de0f08550ce6a1b44c5ac468520146f2 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:25:24 -0400 Subject: [ticket/11088] Fix typo (period instead of comma) PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 73efa3f7f6..7fa853938d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,7 +2465,7 @@ function change_database_data(&$no_updates, $version) 'parent_id' => 0, 'module_enabled' => 1, 'module_display' => 1, - 'module_basename' => ''. + 'module_basename' => '', 'module_class' => 'acp', 'module_mode' => '', 'module_auth' => '', -- cgit v1.2.1 From 30c64f6a01e7d5706c4c0e6b429c1d200f1c3e46 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:37:46 -0400 Subject: [ticket/11088] Untested, progress on update script This should rename Styles category to Customise, move language packs, and add extension management PHPBB3-11088 --- phpBB/install/database_update.php | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7fa853938d..610c591fcc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,19 +2459,31 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } - // Create new Customise ACP tab + // Rename styles module to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $styles_module_id = (int) $row['module_id']; + $db->sql_freeresult($result); + $module_manager = new acp_modules(); $module_manager->update_module_data(array( - 'parent_id' => 0, - 'module_enabled' => 1, - 'module_display' => 1, - 'module_basename' => '', - 'module_class' => 'acp', - 'module_mode' => '', - 'module_auth' => '', + 'module_id' => $styles_module_id, 'module_langname' => 'ACP_CAT_CUSTOMISE', )); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $customise_category_id); + } + $db->sql_freeresult($result); + // Install modules $modules_to_install = array( 'position' => array( @@ -2524,27 +2536,6 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language' OR module_langname = 'styles'"; - $result = $db->sql_query($sql); - $modules_to_move = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - // Next, selec the ID of the new parent module - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; - $result = $db->sql_query($sql); - $customise_category_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - // Now perform the move - foreach ($modules_to_move as $module_id) - { - $module_manager->move_module($module_id, $customise_category_id); - } - // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' -- cgit v1.2.1 From 80f68c358ff9e01d5cf4327c5c0d748e6e6de448 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 11:38:44 -0500 Subject: [ticket/11088] Put language pack module move below extension module creation PHPBB3-11088 --- phpBB/install/database_update.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 610c591fcc..47983676cc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2473,17 +2473,6 @@ function change_database_data(&$no_updates, $version) 'module_langname' => 'ACP_CAT_CUSTOMISE', )); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; - $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) - { - $module_manager->move_module($row['module_id'], $customise_category_id); - } - $db->sql_freeresult($result); - // Install modules $modules_to_install = array( 'position' => array( @@ -2532,6 +2521,16 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Move language management to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $styles_module_id); + } + $db->sql_freeresult($result); + $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From 70aea6fd7c1af79774d800eaafe11c5381e3ff32 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 12:48:27 -0500 Subject: [ticket/11088] Fix the database updater to correctly manipulate the modules PHPBB3-11088 --- phpBB/install/database_update.php | 102 +++++++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 17 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 47983676cc..afc816845d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2460,18 +2460,10 @@ function change_database_data(&$no_updates, $version) } // Rename styles module to Customise - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $styles_module_id = (int) $row['module_id']; - $db->sql_freeresult($result); - - $module_manager = new acp_modules(); - $module_manager->update_module_data(array( - 'module_id' => $styles_module_id, - 'module_langname' => 'ACP_CAT_CUSTOMISE', - )); + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + _sql($sql, $errored, $error_ary); // Install modules $modules_to_install = array( @@ -2510,6 +2502,15 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + // To add a category, the mode and basename must be empty + // The mode is taken from the this array key + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_EXTENSION_MANAGEMENT', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), 'extensions' => array( 'base' => 'acp_extensions', 'class' => 'acp', @@ -2521,15 +2522,46 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); - // Move language management to Customise + // We need a separate array for the new language sub heading + // because it requires another empty key + $modules_to_install = array( + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_LANGUAGE', + 'auth' => 'acl_a_language', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), + ); + + _add_modules($modules_to_install); + + // Move language management to new location in the Customise tab + // First get language module id $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; + WHERE module_basename = 'acp_language'"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + $language_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $db->sql_query($sql); + $language_management_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + if (!class_exists('acp_modules')) { - $module_manager->move_module($row['module_id'], $styles_module_id); + include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); } - $db->sql_freeresult($result); + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($phpbb_root_path . 'includes/functions_acp.' . $phpEx); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; @@ -2861,6 +2893,42 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_clear_prefetch(); } + // Add acl_a_extensions + if (empty($auth_admin->acl_options['id']['a_extensions'])) + { + $auth_admin->acl_add_option(array('global' => array('a_extensions'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['a_']; + $new_id = $auth_admin->acl_options['id']['a_extensions']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_u_chgprofileinfo' -- cgit v1.2.1 From 61adfa502684727f071f85afde08227ebc448232 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:37:39 -0500 Subject: [ticket/11088] Remove extraneous word from sentence in comment PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index afc816845d..1d4c71767b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2503,7 +2503,7 @@ function change_database_data(&$no_updates, $version) 'cat' => 'UCP_PROFILE', ), // To add a category, the mode and basename must be empty - // The mode is taken from the this array key + // The mode is taken from the array key '' => array( 'base' => '', 'class' => 'acp', -- cgit v1.2.1 From 8e4c1526fc3d0b8897886a12dff59808398b2304 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:39:48 -0500 Subject: [ticket/11088] Copy a_styles permission for a_extensions PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1d4c71767b..db5659db7c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2899,7 +2899,7 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_add_option(array('global' => array('a_extensions'))); // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['a_']; + $old_id = $auth_admin->acl_options['id']['a_styles']; $new_id = $auth_admin->acl_options['id']['a_extensions']; $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); -- cgit v1.2.1 From 13f8e64a33a862554cfa185bcf09af9ccdace95c Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:01:58 -0500 Subject: [ticket/11088] Move permission creation to a function PHPBB3-11088 --- phpBB/install/database_update.php | 138 ++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 72 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index db5659db7c..3815f5e8b3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -818,6 +818,69 @@ function _add_modules($modules_to_install) $_module->remove_cache_file(); } +/** +* Add a new permission, optionally copy permission setting from another +* +* @param auth_admin $auth_admin auth_admin object +* @param string $permission_name Name of the permission to add +* @param bool $is_global True is global, false is local +* @param string $copy_from Optional permission name from which to copy +* @return bool true on success, false on failure +*/ +function _add_permission(auth_admin $auth_admin, $permission_name, $is_global = true, $copy_from = '') +{ + // Only add a permission that don't already exist + if (!empty($auth_admin->acl_options['id'][$permission_name])) + { + return true; + } + + $permission_scope = $is_global ? 'global' : 'local'; + + $result = $auth_admin->acl_add_option(array( + $permission_scope => array($permission_name), + )); + + if (!$result) + { + return $result; + } + + // The permission has been added, now we can copy it if needed + if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) + { + $old_id = $auth_admin->acl_options['id'][$copy_from]; + $new_id = $auth_admin->acl_options['id'][$permission_name]; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + $auth_admin->acl_clear_prefetch(); + } + + return true; +} + /**************************************************************************** * ADD YOUR DATABASE SCHEMA CHANGES HERE * *****************************************************************************/ @@ -2853,81 +2916,12 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); - // Add new permission u_chgprofileinfo and duplicate settings from u_sig + // Add new permissions include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_chgprofileinfo'])) - { - $auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_sig']; - $new_id = $auth_admin->acl_options['id']['u_chgprofileinfo']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - // Add acl_a_extensions - if (empty($auth_admin->acl_options['id']['a_extensions'])) - { - $auth_admin->acl_add_option(array('global' => array('a_extensions'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['a_styles']; - $new_id = $auth_admin->acl_options['id']['a_extensions']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } + _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); + _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From 5fc6752178ebc814c83b88b5891c568273d36c94 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:04:20 -0500 Subject: [ticket/11088] Globalize objects in new permission function PHPBB3-11088 --- phpBB/install/database_update.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3815f5e8b3..fb762c6137 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -827,8 +827,9 @@ function _add_modules($modules_to_install) * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission(auth_admin $auth_admin, $permission_name, $is_global = true, $copy_from = '') +function _add_permission($permission_name, $is_global = true, $copy_from = '') { + global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2920,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); - _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); + _add_permission('u_chgprofileinfo', true, 'u_sig'); + _add_permission('a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From a5783211c90e226a9d1a2b3636f63f1a80aced19 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:19:06 -0500 Subject: [ticket/11088] Pass required objects in as arguments PHPBB3-11088 --- phpBB/install/database_update.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb762c6137..7aa346b817 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -822,14 +822,14 @@ function _add_modules($modules_to_install) * Add a new permission, optionally copy permission setting from another * * @param auth_admin $auth_admin auth_admin object +* @param dbal $db Database object * @param string $permission_name Name of the permission to add * @param bool $is_global True is global, false is local * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission($permission_name, $is_global = true, $copy_from = '') +function _add_permission(auth_admin $auth_admin, dbal $db, $permission_name, $is_global = true, $copy_from = '') { - global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2921,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission('u_chgprofileinfo', true, 'u_sig'); - _add_permission('a_extensions', true, 'a_styles'); + _add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig'); + _add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From 1a1ae1b663079792c775c4a51d5aaaf0259fb05c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 13 Dec 2012 18:00:29 -0500 Subject: [ticket/11015] Change permission adding in database updater to new style. PHPBB3-11015 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 9afb5cc963..19d0d35fc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -821,13 +821,13 @@ function _add_modules($modules_to_install) * Add a new permission, optionally copy permission setting from another * * @param auth_admin $auth_admin auth_admin object -* @param dbal $db Database object +* @param phpbb_db_driver $db Database object * @param string $permission_name Name of the permission to add * @param bool $is_global True is global, false is local * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission(auth_admin $auth_admin, dbal $db, $permission_name, $is_global = true, $copy_from = '') +function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '') { // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) -- cgit v1.2.1