[ticket/11363] Load module info files for extensions too

Use the acp_modules::get_module_infos function instead of our own include code

PHPBB3-11363
This commit is contained in:
Nathaniel Guse 2013-02-27 11:12:18 -06:00
parent 80bd78a5e5
commit d296e809d5

View file

@ -183,25 +183,13 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$basename = str_replace(array('/', '\\'), '', $basename); $basename = str_replace(array('/', '\\'), '', $basename);
$class = str_replace(array('/', '\\'), '', $class); $class = str_replace(array('/', '\\'), '', $class);
$include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path; if (!class_exists('acp_modules'))
$info_file = "$class/info/$basename.{$this->php_ext}";
// The manual and automatic ways both failed...
if (!file_exists($include_path . $info_file))
{ {
throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $info_file); include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
} }
$acp_modules = new acp_modules();
$classname = "{$basename}_info"; $module = $acp_modules->get_module_infos($basename, $class);
unset($acp_modules);
if (!class_exists($classname))
{
include($include_path . $info_file);
}
$info = new $classname;
$module = $info->module();
unset($info);
$result = ''; $result = '';
foreach ($module['modes'] as $mode => $module_info) foreach ($module['modes'] as $mode => $module_info)
@ -373,30 +361,19 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$basename = str_replace(array('/', '\\'), '', $module['module_basename']); $basename = str_replace(array('/', '\\'), '', $module['module_basename']);
$class = str_replace(array('/', '\\'), '', $class); $class = str_replace(array('/', '\\'), '', $class);
$include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path; if (!class_exists('acp_modules'))
$info_file = "$class/info/$basename.{$this->php_ext}";
if (!file_exists($include_path . $info_file))
{ {
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file); include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
} }
$acp_modules = new acp_modules();
$classname = "{$basename}_info"; $module_info = $acp_modules->get_module_infos($basename, $class);
unset($acp_modules);
if (!class_exists($classname))
{
include($include_path . $info_file);
}
$info = new $classname;
$module_info = $info->module();
unset($info);
foreach ($module_info['modes'] as $mode => $info) foreach ($module_info['modes'] as $mode => $info)
{ {
if (!isset($module['modes']) || in_array($mode, $module['modes'])) if (!isset($module['modes']) || in_array($mode, $module['modes']))
{ {
$this->remove($class, $parent, $info['title']) . '<br />'; $this->remove($class, $parent, $info['title']);
} }
} }
} }