aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateBartus <mate.bartus@gmail.com>2015-05-31 13:21:45 +0200
committerMateBartus <mate.bartus@gmail.com>2015-05-31 13:22:45 +0200
commit77ee0e62ca1685e4577947cc60163367dfa97de6 (patch)
treead9ac0d6fc644cf1aa36f891c454523130b21f74
parente877a752be55dfda5a72c7995708e4e132a1079d (diff)
downloadforums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.gz
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.bz2
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.tar.xz
forums-77ee0e62ca1685e4577947cc60163367dfa97de6.zip
[ticket/13777] Use module manager in phpBB core files
PHPBB3-13777
-rw-r--r--phpBB/install/install_install.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php11
-rw-r--r--phpBB/phpbb/db/migration/data/v310/dev.php11
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php55
4 files changed, 47 insertions, 71 deletions
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index e8890a3d08..ce457aaef5 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1552,9 +1552,14 @@ class install_install extends module
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
}
- include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
-
- $_module = new acp_modules();
+ $_module = new \phpbb\module\module_manager(
+ new \phpbb\cache\driver\dummy(),
+ $db,
+ $phpbb_extension_manager,
+ MODULES_TABLE,
+ $phpbb_root_path,
+ $phpEx
+ );
$module_classes = array('acp', 'mcp', 'ucp');
// Add categories
@@ -1585,7 +1590,7 @@ class install_install extends module
);
// Add category
- $_module->update_module_data($module_data, true);
+ $_module->update_module_data($module_data);
// Check for last sql error happened
if ($db->get_sql_error_triggered())
@@ -1619,7 +1624,7 @@ class install_install extends module
'module_auth' => '',
);
- $_module->update_module_data($module_data, true);
+ $_module->update_module_data($module_data);
// Check for last sql error happened
if ($db->get_sql_error_triggered())
@@ -1659,7 +1664,7 @@ class install_install extends module
'module_auth' => $row['auth'],
);
- $_module->update_module_data($module_data, true);
+ $_module->update_module_data($module_data);
// Check for last sql error happened
if ($db->get_sql_error_triggered())
@@ -1684,7 +1689,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_up', 4);
+ $_module->move_module_by($row, 'acp', 'move_up', 4);
// Move permissions intro screen module 4 up...
$sql = 'SELECT *
@@ -1696,7 +1701,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_up', 4);
+ $_module->move_module_by($row, 'acp', 'move_up', 4);
// Move manage users screen module 5 up...
$sql = 'SELECT *
@@ -1708,7 +1713,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_up', 5);
+ $_module->move_module_by($row, 'acp', 'move_up', 5);
// Move extension management module 1 up...
$sql = 'SELECT *
@@ -1721,7 +1726,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_up', 1);
+ $_module->move_module_by($row, 'acp', 'move_up', 1);
}
if ($module_class == 'mcp')
@@ -1736,7 +1741,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 3);
+ $_module->move_module_by($row, 'mcp', 'move_down', 3);
// Move closed pm reports module 3 down...
$sql = 'SELECT *
@@ -1748,7 +1753,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 3);
+ $_module->move_module_by($row, 'mcp', 'move_down', 3);
// Move open pm reports module 3 down...
$sql = 'SELECT *
@@ -1760,7 +1765,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 3);
+ $_module->move_module_by($row, 'mcp', 'move_down', 3);
}
if ($module_class == 'ucp')
@@ -1775,7 +1780,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 4);
+ $_module->move_module_by($row, 'ucp', 'move_down', 4);
// Move notification options module 4 down...
$sql = 'SELECT *
@@ -1787,7 +1792,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 4);
+ $_module->move_module_by($row, 'ucp', 'move_down', 4);
// Move OAuth module 5 down...
$sql = 'SELECT *
@@ -1799,7 +1804,7 @@ class install_install extends module
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $_module->move_module_by($row, 'move_down', 5);
+ $_module->move_module_by($row, 'ucp', 'move_down', 5);
}
// And now for the special ones
@@ -1838,7 +1843,7 @@ class install_install extends module
'module_auth' => $row['module_auth'],
);
- $_module->update_module_data($module_data, true);
+ $_module->update_module_data($module_data);
// Check for last sql error happened
if ($db->get_sql_error_triggered())
@@ -1850,7 +1855,7 @@ class install_install extends module
}
}
- $_module->remove_cache_file();
+ $_module->remove_cache_file($module_class);
}
}
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/dev.php b/phpBB/phpbb/db/migration/data/v310/dev.php
index f037191c2a..250258eea7 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()
{
@@ -204,18 +204,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/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index b6f0372181..3b181872db 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;
@@ -42,15 +47,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;
@@ -188,7 +195,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']))
@@ -239,13 +245,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
return;
}
- 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,
@@ -256,16 +255,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
'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
+ try
{
+ $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', $user->data['user_id'], $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name));
@@ -318,6 +312,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
$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");
@@ -417,21 +416,9 @@ 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");
@@ -474,13 +461,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($basename, $class, true);
if (empty($module))
{