aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/module/install_data
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2016-02-16 00:11:27 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-02-16 00:11:27 +0100
commit8d1eee0e0118510def943e43e3246b2b89a08bdc (patch)
tree478bf6c878bacec7c4e60832e0af7d106bd52e52 /phpBB/phpbb/install/module/install_data
parent1f0b6c8123cdecf2f5f1855ad52a90ef962809a4 (diff)
parentd0ce6a18df2172a6e9baf1f1c2802efb30b25323 (diff)
downloadforums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.gz
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.bz2
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.tar.xz
forums-8d1eee0e0118510def943e43e3246b2b89a08bdc.zip
Merge branch '3.2.x'
* 3.2.x: [ticket/14462] Not show timeout messages in convertors [ticket/14462] Make timeout error translateable [ticket/14462] Update ordering in install db config [ticket/14462] Fix comments [ticket/14462] Fix tests [ticket/14462] Fix CS and typo [ticket/14462] Set instance of db driver for database access using global [ticket/14462] Fix installation in tests [ticket/14462] Refactor tasks to be more modular [ticket/14462] Further speed improvements
Diffstat (limited to 'phpBB/phpbb/install/module/install_data')
-rw-r--r--phpBB/phpbb/install/module/install_data/task/add_bots.php22
-rw-r--r--phpBB/phpbb/install/module/install_data/task/add_modules.php428
2 files changed, 288 insertions, 162 deletions
diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php
index 2ee641ff63..d45a6839a0 100644
--- a/phpBB/phpbb/install/module/install_data/task/add_bots.php
+++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php
@@ -13,6 +13,8 @@
namespace phpbb\install\module\install_data\task;
+use phpbb\install\exception\resource_limit_reached_exception;
+
class add_bots extends \phpbb\install\task_base
{
/**
@@ -179,7 +181,10 @@ class add_bots extends \phpbb\install\task_base
$this->io_handler->add_error_message('NO_GROUP');
}
- foreach ($this->bot_list as $bot_name => $bot_ary)
+ $i = $this->install_config->get('add_bot_index', 0);
+ $bot_list = array_slice($this->bot_list, $i);
+
+ foreach ($bot_list as $bot_name => $bot_ary)
{
$user_row = array(
'user_type' => USER_IGNORE,
@@ -221,6 +226,21 @@ class add_bots extends \phpbb\install\task_base
));
$this->db->sql_query($sql);
+
+ $i++;
+
+ // Stop execution if resource limit is reached
+ if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
+ {
+ break;
+ }
+ }
+
+ $this->install_config->set('add_bot_index', $i);
+
+ if ($i < sizeof($this->bot_list))
+ {
+ throw new resource_limit_reached_exception();
}
}
diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php
index bfbe6282bc..d21a5be823 100644
--- a/phpBB/phpbb/install/module/install_data/task/add_modules.php
+++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php
@@ -13,9 +13,19 @@
namespace phpbb\install\module\install_data\task;
+use phpbb\install\exception\resource_limit_reached_exception;
+use phpbb\install\helper\config;
+use phpbb\install\helper\container_factory;
+use phpbb\install\helper\iohandler\iohandler_interface;
+
class add_modules extends \phpbb\install\task_base
{
/**
+ * @var config
+ */
+ protected $config;
+
+ /**
* @var \phpbb\db\driver\driver_interface
*/
protected $db;
@@ -136,12 +146,13 @@ class add_modules extends \phpbb\install\task_base
/**
* Constructor
*
- * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
- * @param \phpbb\install\helper\container_factory $container Installer's DI container
+ * @parma config $config Installer's config
+ * @param iohandler_interface $iohandler Installer's input-output handler
+ * @param container_factory $container Installer's DI container
*/
- public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
- \phpbb\install\helper\container_factory $container)
+ public function __construct(config $config, iohandler_interface $iohandler, container_factory $container)
{
+ $this->config = $config;
$this->db = $container->get('dbal.conn');
$this->extension_manager = $container->get('ext.manager');
$this->iohandler = $iohandler;
@@ -158,11 +169,19 @@ class add_modules extends \phpbb\install\task_base
$this->db->sql_return_on_error(true);
$module_classes = array('acp', 'mcp', 'ucp');
+ $total = sizeof($module_classes);
+ $i = $this->config->get('module_class_index', 0);
+ $module_classes = array_slice($module_classes, $i);
+
foreach ($module_classes as $module_class)
{
- $categories = array();
+ $categories = $this->config->get('module_categories_array', array());
+
+ $k = $this->config->get('module_categories_index', 0);
+ $module_categories = array_slice($this->module_categories[$module_class], $k);
+ $timed_out = false;
- foreach ($this->module_categories[$module_class] as $cat_name => $subs)
+ foreach ($module_categories as $cat_name => $subs)
{
// Check if this sub-category has a basename. If it has, use it.
$basename = (isset($this->module_categories_basenames[$cat_name])) ? $this->module_categories_basenames[$cat_name] : '';
@@ -221,11 +240,31 @@ class add_modules extends \phpbb\install\task_base
$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
}
}
+
+ $k++;
+
+ // Stop execution if resource limit is reached
+ if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0)
+ {
+ $timed_out = true;
+ break;
+ }
+ }
+
+ $this->config->set('module_categories_array', $categories);
+ $this->config->set('module_categories_index', $k);
+
+ if ($timed_out)
+ {
+ throw new resource_limit_reached_exception();
}
// Get the modules we want to add... returned sorted by name
$module_info = $this->module_manager->get_module_infos($module_class);
+ $k = $this->config->get('module_info_index', 0);
+ $module_info = array_slice($module_info, $k);
+
foreach ($module_info as $module_basename => $fileinfo)
{
foreach ($fileinfo['modes'] as $module_mode => $row)
@@ -258,189 +297,256 @@ class add_modules extends \phpbb\install\task_base
}
}
}
- }
- // Move some of the modules around since the code above will put them in the wrong place
- if ($module_class === 'acp')
- {
- // Move main module 4 up...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'acp_main'
- AND module_class = 'acp'
- AND module_mode = 'main'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ $k++;
- $this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
-
- // Move permissions intro screen module 4 up...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'acp_permissions'
- AND module_class = 'acp'
- AND module_mode = 'intro'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ // Stop execution if resource limit is reached
+ if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0)
+ {
+ $timed_out = true;
+ break;
+ }
+ }
- $this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
+ $this->config->set('module_info_index', $k);
- // Move manage users screen module 5 up...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'acp_users'
- AND module_class = 'acp'
- AND module_mode = 'overview'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $this->module_manager->move_module_by($row, 'acp', 'move_up', 5);
+ // Stop execution if resource limit is reached
+ if ($timed_out)
+ {
+ throw new resource_limit_reached_exception();
+ }
- // Move extension management module 1 up...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT'
- AND module_class = 'acp'
- AND module_mode = ''
- AND module_basename = ''";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ // Move some of the modules around since the code above will put them in the wrong place
+ if (!$this->config->get('modules_ordered', false))
+ {
+ $this->order_modules($module_class);
+ $this->config->set('modules_ordered', true);
- $this->module_manager->move_module_by($row, 'acp', 'move_up', 1);
+ // Stop execution if resource limit is reached
+ if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0)
+ {
+ throw new resource_limit_reached_exception();
+ }
}
- if ($module_class == 'mcp')
+ // And now for the special ones
+ // (these are modules which appear in multiple categories and thus get added manually
+ // to some for more control)
+ if (isset($this->module_extras[$module_class]))
{
- // Move pm report details module 3 down...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'mcp_pm_reports'
- AND module_class = 'mcp'
- AND module_mode = 'pm_report_details'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ $this->add_module_extras($module_class);
+ }
- $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+ $this->module_manager->remove_cache_file($module_class);
- // Move closed pm reports module 3 down...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'mcp_pm_reports'
- AND module_class = 'mcp'
- AND module_mode = 'pm_reports_closed'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ $i++;
- $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+ $this->config->set('module_class_index', $i);
+ $this->config->set('module_categories_index', 0);
+ $this->config->set('module_info_index', 0);
+ $this->config->set('added_extra_modules', false);
+ $this->config->set('modules_ordered', false);
+ $this->config->set('module_categories_array', array());
- // Move open pm reports module 3 down...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'mcp_pm_reports'
- AND module_class = 'mcp'
- AND module_mode = 'pm_reports'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+ // Stop execution if resource limit is reached
+ if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0)
+ {
+ break;
}
+ }
- if ($module_class == 'ucp')
- {
- // Move attachment module 4 down...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'ucp_attachments'
- AND module_class = 'ucp'
- AND module_mode = 'attachments'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ if ($i < $total)
+ {
+ throw new resource_limit_reached_exception();
+ }
+ }
- $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
+ /**
+ * Move modules to their correct place
+ *
+ * @param string $module_class
+ */
+ protected function order_modules($module_class)
+ {
+ if ($module_class == 'acp')
+ {
+ // Move main module 4 up...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'acp_main'
+ AND module_class = 'acp'
+ AND module_mode = 'main'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
+
+ // Move permissions intro screen module 4 up...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'acp_permissions'
+ AND module_class = 'acp'
+ AND module_mode = 'intro'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
+
+ // Move manage users screen module 5 up...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'acp_users'
+ AND module_class = 'acp'
+ AND module_mode = 'overview'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'acp', 'move_up', 5);
+
+ // Move extension management module 1 up...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT'
+ AND module_class = 'acp'
+ AND module_mode = ''
+ AND module_basename = ''";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'acp', 'move_up', 1);
+ }
- // Move notification options module 4 down...
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'ucp_notifications'
- AND module_class = 'ucp'
- AND module_mode = 'notification_options'";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ if ($module_class == 'mcp')
+ {
+ // Move pm report details module 3 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'mcp_pm_reports'
+ AND module_class = 'mcp'
+ AND module_mode = 'pm_report_details'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+
+ // Move closed pm reports module 3 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'mcp_pm_reports'
+ AND module_class = 'mcp'
+ AND module_mode = 'pm_reports_closed'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+
+ // Move open pm reports module 3 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'mcp_pm_reports'
+ AND module_class = 'mcp'
+ AND module_mode = 'pm_reports'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
+ }
- $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
+ if ($module_class == 'ucp')
+ {
+ // Move attachment module 4 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'ucp_attachments'
+ AND module_class = 'ucp'
+ AND module_mode = 'attachments'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
+
+ // Move notification options module 4 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'ucp_notifications'
+ AND module_class = 'ucp'
+ AND module_mode = 'notification_options'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
+
+ // Move OAuth module 5 down...
+ $sql = 'SELECT *
+ FROM ' . MODULES_TABLE . "
+ WHERE module_basename = 'ucp_auth_link'
+ AND module_class = 'ucp'
+ AND module_mode = 'auth_link'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->module_manager->move_module_by($row, 'ucp', 'move_down', 5);
+ }
+ }
- // Move OAuth module 5 down...
+ /**
+ * Add extra modules
+ *
+ * @param string $module_class
+ */
+ protected function add_module_extras($module_class)
+ {
+ foreach ($this->module_extras[$module_class] as $cat_name => $mods)
+ {
+ $sql = 'SELECT module_id, left_id, right_id
+ FROM ' . MODULES_TABLE . "
+ WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "'
+ AND module_class = '" . $this->db->sql_escape($module_class) . "'";
+ $result = $this->db->sql_query_limit($sql, 1);
+ $row2 = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ foreach ($mods as $mod_name)
+ {
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'ucp_auth_link'
- AND module_class = 'ucp'
- AND module_mode = 'auth_link'";
- $result = $this->db->sql_query($sql);
+ WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "'
+ AND module_class = '" . $this->db->sql_escape($module_class) . "'
+ AND module_basename <> ''";
+ $result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $this->module_manager->move_module_by($row, 'ucp', 'move_down', 5);
- }
-
- // And now for the special ones
- // (these are modules which appear in multiple categories and thus get added manually
- // to some for more control)
- if (isset($this->module_extras[$module_class]))
- {
- foreach ($this->module_extras[$module_class] as $cat_name => $mods)
- {
- $sql = 'SELECT module_id, left_id, right_id
- FROM ' . MODULES_TABLE . "
- WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "'
- AND module_class = '" . $this->db->sql_escape($module_class) . "'";
- $result = $this->db->sql_query_limit($sql, 1);
- $row2 = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- foreach ($mods as $mod_name)
- {
- $sql = 'SELECT *
- FROM ' . MODULES_TABLE . "
- WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "'
- AND module_class = '" . $this->db->sql_escape($module_class) . "'
- AND module_basename <> ''";
- $result = $this->db->sql_query_limit($sql, 1);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $module_data = array(
- 'module_basename' => $row['module_basename'],
- 'module_enabled' => (int) $row['module_enabled'],
- 'module_display' => (int) $row['module_display'],
- 'parent_id' => (int) $row2['module_id'],
- 'module_class' => $row['module_class'],
- 'module_langname' => $row['module_langname'],
- 'module_mode' => $row['module_mode'],
- 'module_auth' => $row['module_auth'],
- );
+ $module_data = array(
+ 'module_basename' => $row['module_basename'],
+ 'module_enabled' => (int) $row['module_enabled'],
+ 'module_display' => (int) $row['module_display'],
+ 'parent_id' => (int) $row2['module_id'],
+ 'module_class' => $row['module_class'],
+ 'module_langname' => $row['module_langname'],
+ 'module_mode' => $row['module_mode'],
+ 'module_auth' => $row['module_auth'],
+ );
- $this->module_manager->update_module_data($module_data);
+ $this->module_manager->update_module_data($module_data);
- // Check for last sql error happened
- if ($this->db->get_sql_error_triggered())
- {
- $error = $this->db->sql_error($this->db->get_sql_error_sql());
- $this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
- }
- }
+ // Check for last sql error happened
+ if ($this->db->get_sql_error_triggered())
+ {
+ $error = $this->db->sql_error($this->db->get_sql_error_sql());
+ $this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
-
- $this->module_manager->remove_cache_file($module_class);
}
}