aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_extensions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_extensions.php')
-rw-r--r--phpBB/includes/acp/acp_extensions.php173
1 files changed, 97 insertions, 76 deletions
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index ef5f78d5bf..6dd0f534c7 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -11,6 +11,9 @@
*
*/
+use phpbb\exception\exception_interface;
+use phpbb\exception\version_check_exception;
+
/**
* @ignore
*/
@@ -34,7 +37,7 @@ class acp_extensions
function main()
{
// Start the page
- global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx, $phpbb_log, $cache, $phpbb_dispatcher;
+ global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpbb_log, $cache, $phpbb_dispatcher;
$this->db = $db;
$this->config = $config;
@@ -93,15 +96,16 @@ class acp_extensions
// If they've specified an extension, let's load the metadata manager and validate it.
if ($ext_name)
{
- $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $user, $phpbb_root_path);
+ $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $phpbb_root_path);
try
{
$md_manager->get_metadata('all');
}
- catch (\phpbb\extension\exception $e)
+ catch (exception_interface $e)
{
- trigger_error($e, E_USER_WARNING);
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ trigger_error($message, E_USER_WARNING);
}
}
@@ -311,29 +315,39 @@ class acp_extensions
case 'details':
// Output it to the template
- $md_manager->output_template_data();
+ $md_manager->output_template_data($template);
- try
+ $meta = $md_manager->get_metadata('all');
+ if (isset($meta['extra']['version-check']))
{
- $updates_available = $this->version_check($md_manager, $request->variable('versioncheck_force', false));
+ try
+ {
+ $updates_available = $phpbb_extension_manager->version_check($md_manager, $request->variable('versioncheck_force', false), $this->config['extension_force_unstable'] ? 'unstable' : null);
- $template->assign_vars(array(
- 'S_UP_TO_DATE' => empty($updates_available),
- 'S_VERSIONCHECK' => true,
- 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
- ));
+ $template->assign_vars(array(
+ 'S_UP_TO_DATE' => empty($updates_available),
+ 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
+ ));
- foreach ($updates_available as $branch => $version_data)
+ foreach ($updates_available as $branch => $version_data)
+ {
+ $template->assign_block_vars('updates_available', $version_data);
+ }
+ }
+ catch (exception_interface $e)
{
- $template->assign_block_vars('updates_available', $version_data);
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+
+ $template->assign_vars(array(
+ 'S_VERSIONCHECK_FAIL' => true,
+ 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '',
+ ));
}
+ $template->assign_var('S_VERSIONCHECK', true);
}
- catch (\RuntimeException $e)
+ else
{
- $template->assign_vars(array(
- 'S_VERSIONCHECK_STATUS' => $e->getCode(),
- 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
- ));
+ $template->assign_var('S_VERSIONCHECK', false);
}
$template->assign_vars(array(
@@ -379,7 +393,7 @@ class acp_extensions
foreach ($phpbb_extension_manager->all_enabled() as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
try
{
@@ -389,17 +403,32 @@ class acp_extensions
'META_VERSION' => $meta['version'],
);
- $force_update = $this->request->variable('versioncheck_force', false);
- $updates = $this->version_check($md_manager, $force_update, !$force_update);
+ if (isset($meta['extra']['version-check']))
+ {
+ try
+ {
+ $force_update = $this->request->variable('versioncheck_force', false);
+ $updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
- $enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
- $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
- $enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ $enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
+ $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
+ $enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ }
+ catch (exception_interface $e)
+ {
+ // Ignore exceptions due to the version check
+ }
+ }
+ else
+ {
+ $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ }
}
- catch (\phpbb\extension\exception $e)
+ catch (exception_interface $e)
{
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
@@ -436,7 +465,7 @@ class acp_extensions
foreach ($phpbb_extension_manager->all_disabled() as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
try
{
@@ -446,23 +475,35 @@ class acp_extensions
'META_VERSION' => $meta['version'],
);
- $force_update = $this->request->variable('versioncheck_force', false);
- $updates = $this->version_check($md_manager, $force_update, !$force_update);
+ if (isset($meta['extra']['version-check']))
+ {
+ $force_update = $this->request->variable('versioncheck_force', false);
+ $updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
- $disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
- $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
- $disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ $disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
+ $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
+ $disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ }
+ else
+ {
+ $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ }
}
- catch (\phpbb\extension\exception $e)
+ catch (version_check_exception $e)
{
+ $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ }
+ catch (exception_interface $e)
+ {
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
catch (\RuntimeException $e)
{
- $disabeld_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
}
}
@@ -496,7 +537,7 @@ class acp_extensions
foreach ($uninstalled as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
try
{
@@ -506,24 +547,32 @@ class acp_extensions
'META_VERSION' => $meta['version'],
);
- $force_update = $this->request->variable('versioncheck_force', false);
- $updates = $this->version_check($md_manager, $force_update, !$force_update);
+ if (isset($meta['extra']['version-check']))
+ {
+ $force_update = $this->request->variable('versioncheck_force', false);
+ $updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
- $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
- $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
- $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
+ $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
+ $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
+ }
+ else
+ {
+ $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ }
}
- catch (\phpbb\extension\exception $e)
+ catch (version_check_exception $e)
{
+ $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
+ }
+ catch (exception_interface $e)
+ {
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
- catch (\RuntimeException $e)
- {
- $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
- }
}
uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table'));
@@ -560,34 +609,6 @@ class acp_extensions
}
/**
- * Check the version and return the available updates.
- *
- * @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
- * @param bool $force_update Ignores cached data. Defaults to false.
- * @param bool $force_cache Force the use of the cache. Override $force_update.
- * @return string
- * @throws RuntimeException
- */
- protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
- {
- $meta = $md_manager->get_metadata('all');
-
- if (!isset($meta['extra']['version-check']))
- {
- throw new \RuntimeException($this->user->lang('NO_VERSIONCHECK'), 1);
- }
-
- $version_check = $meta['extra']['version-check'];
-
- $version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), $this->user);
- $version_helper->set_current_version($meta['version']);
- $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename'], isset($version_check['ssl']) ? $version_check['ssl'] : false);
- $version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
-
- return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
- }
-
- /**
* Sort helper for the table containing the metadata about the extensions.
*/
protected function sort_extension_meta_data_table($val1, $val2)