aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2015-08-24 12:33:32 +0200
committerTristan Darricau <github@nicofuma.fr>2016-12-03 16:37:35 +0100
commit8481bd4e1831e3f9911263957637f4095fb088b0 (patch)
tree38f1b70929abfa155cea422172e6301a1ed03d2a /phpBB/phpbb
parent376042d845a18058d93d289a1227096794da06d2 (diff)
downloadforums-8481bd4e1831e3f9911263957637f4095fb088b0.tar
forums-8481bd4e1831e3f9911263957637f4095fb088b0.tar.gz
forums-8481bd4e1831e3f9911263957637f4095fb088b0.tar.bz2
forums-8481bd4e1831e3f9911263957637f4095fb088b0.tar.xz
forums-8481bd4e1831e3f9911263957637f4095fb088b0.zip
[ticket/12610] Use exception_interface
PHPBB3-12610
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/console/command/update/check.php32
-rw-r--r--phpBB/phpbb/extension/manager.php8
-rw-r--r--phpBB/phpbb/version_helper.php33
3 files changed, 25 insertions, 48 deletions
diff --git a/phpBB/phpbb/console/command/update/check.php b/phpBB/phpbb/console/command/update/check.php
index 0ef3c970ac..982c86bf8c 100644
--- a/phpBB/phpbb/console/command/update/check.php
+++ b/phpBB/phpbb/console/command/update/check.php
@@ -13,6 +13,7 @@
namespace phpbb\console\command\update;
+use phpbb\exception\exception_interface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
@@ -116,18 +117,9 @@ class check extends \phpbb\console\command\command
*/
protected function check_ext(InputInterface $input, OutputInterface $output, $stability, $recheck, $ext_name)
{
- try
- {
- $ext_manager = $this->phpbb_container->get('ext.manager');
- $md_manager = $ext_manager->create_extension_metadata_manager($ext_name, null);
- $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
- }
- catch (\RuntimeException $e)
- {
- $output->writeln('<error>' . $e->getMessage() . '</error>');
-
- return 2;
- }
+ $ext_manager = $this->phpbb_container->get('ext.manager');
+ $md_manager = $ext_manager->create_extension_metadata_manager($ext_name, null);
+ $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
$metadata = $md_manager->get_metadata('all');
if ($input->getOption('verbose'))
@@ -178,16 +170,7 @@ class check extends \phpbb\console\command\command
$version_helper = $this->phpbb_container->get('version_helper');
$version_helper->force_stability($stability);
- try
- {
- $updates_available = $version_helper->get_suggested_updates($recheck);
- }
- catch (\RuntimeException $e)
- {
- $output->writeln('<error>' . $this->user->lang('VERSIONCHECK_FAIL') . '</error>');
-
- return 2;
- }
+ $updates_available = $version_helper->get_suggested_updates($recheck);
if ($input->getOption('verbose'))
{
@@ -258,6 +241,11 @@ class check extends \phpbb\console\command\command
$message .= ' | ';
}
}
+ catch (exception_interface $e)
+ {
+ $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $message .= ('<error>' . $exception_message . '</error>');
+ }
catch (\RuntimeException $e)
{
$message .= ('<error>' . $e->getMessage() . '</error>');
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index 6cdc8c0cc7..da1f06c885 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -13,6 +13,8 @@
namespace phpbb\extension;
+use phpbb\exception\runtime_exception;
+use phpbb\file_downloader;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -572,7 +574,7 @@ class manager
* @param bool $force_cache Force the use of the cache. Override $force_update.
* @param string $stability Force the stability (null by default).
* @return string
- * @throws \RuntimeException
+ * @throws runtime_exception
*/
public function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false, $stability = null)
{
@@ -580,12 +582,12 @@ class manager
if (!isset($meta['extra']['version-check']))
{
- throw new \RuntimeException($this->user->lang('NO_VERSIONCHECK'), 1);
+ throw new runtime_exception('NO_VERSIONCHECK');
}
$version_check = $meta['extra']['version-check'];
- $version_helper = new \phpbb\version_helper($this->cache, $this->config, $this->user);
+ $version_helper = new \phpbb\version_helper($this->cache, $this->config, new file_downloader());
$version_helper->set_current_version($meta['version']);
$version_helper->set_file_location($version_check ['host'], $version_check ['directory'], $version_check ['filename']);
$version_helper->force_stability($stability);
diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php
index a1e66ba8fe..227bb72403 100644
--- a/phpBB/phpbb/version_helper.php
+++ b/phpBB/phpbb/version_helper.php
@@ -12,6 +12,7 @@
*/
namespace phpbb;
+use phpbb\exception\runtime_exception;
/**
* Class to handle version checking and comparison
@@ -58,23 +59,18 @@ class version_helper
/** @var \phpbb\file_downloader */
protected $file_downloader;
- /** @var \phpbb\user */
- protected $user;
-
/**
* Constructor
*
* @param \phpbb\cache\service $cache
* @param \phpbb\config\config $config
* @param \phpbb\file_downloader $file_downloader
- * @param \phpbb\user $user
*/
- public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader, \phpbb\user $user)
+ public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader)
{
$this->cache = $cache;
$this->config = $config;
$this->file_downloader = $file_downloader;
- $this->user = $user;
if (defined('PHPBB_QA'))
{
@@ -175,7 +171,7 @@ class version_helper
* @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
+ * @throws runtime_exception
*/
public function get_latest_on_current_branch($force_update = false, $force_cache = false)
{
@@ -206,7 +202,7 @@ class version_helper
* @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
+ * @throws runtime_exception
*/
public function get_suggested_updates($force_update = false, $force_cache = false)
{
@@ -227,7 +223,7 @@ class version_helper
* @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 Version info
- * @throws \RuntimeException
+ * @throws runtime_exception
*/
public function get_versions_matching_stability($force_update = false, $force_cache = false)
{
@@ -247,7 +243,7 @@ class version_helper
* @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 Version info, includes stable and unstable data
- * @throws \RuntimeException
+ * @throws runtime_exception
*/
public function get_versions($force_update = false, $force_cache = false)
{
@@ -257,23 +253,16 @@ class version_helper
if ($info === false && $force_cache)
{
- throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
+ throw new runtime_exception('VERSIONCHECK_FAIL');
}
else if ($info === false || $force_update)
{
- try {
- $info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80);
- }
- catch (\phpbb\exception\runtime_exception $exception)
- {
- $prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters());
- throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $prepare_parameters));
- }
+ $info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80);
$error_string = $this->file_downloader->get_error_string();
if (!empty($error_string))
{
- throw new \RuntimeException($error_string);
+ throw new runtime_exception($error_string);
}
$info = json_decode($info, true);
@@ -290,9 +279,7 @@ class version_helper
if (empty($info['stable']) && empty($info['unstable']))
{
- $this->user->add_lang('acp/common');
-
- throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
+ throw new runtime_exception('VERSIONCHECK_FAIL');
}
$info['stable'] = (empty($info['stable'])) ? array() : $info['stable'];