From 57915a8aaa842064d42fee419c9e0eaf7288140a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 1 Sep 2016 16:12:04 +0200 Subject: [PATCH] [ticket/12610] Correctly handle empty cache PHPBB3-12610 --- .../default/container/services_console.yml | 6 +++--- phpBB/ext/index.htm | 10 +++++++++ phpBB/includes/acp/acp_extensions.php | 9 ++++---- .../exception/version_check_exception.php | 21 +++++++++++++++++++ phpBB/phpbb/version_helper.php | 16 +++++++------- 5 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 phpBB/ext/index.htm create mode 100644 phpBB/phpbb/exception/version_check_exception.php diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index c3db4c29a5..4420b6e345 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -223,9 +223,9 @@ services: console.command.update.check: class: phpbb\console\command\update\check arguments: - - @user - - @config - - @service_container + - '@user' + - '@config' + - '@service_container' tags: - { name: console.command } diff --git a/phpBB/ext/index.htm b/phpBB/ext/index.htm new file mode 100644 index 0000000000..ee1f723a7d --- /dev/null +++ b/phpBB/ext/index.htm @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 904dd2e960..ea6feb3e6a 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -12,6 +12,7 @@ */ use phpbb\exception\exception_interface; +use phpbb\exception\version_check_exception; /** * @ignore @@ -518,6 +519,10 @@ class acp_extensions $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; } } + 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())); @@ -526,10 +531,6 @@ class acp_extensions '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')); diff --git a/phpBB/phpbb/exception/version_check_exception.php b/phpBB/phpbb/exception/version_check_exception.php new file mode 100644 index 0000000000..0810263ade --- /dev/null +++ b/phpBB/phpbb/exception/version_check_exception.php @@ -0,0 +1,21 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\exception; + +/** + * Define an exception related to the version checker. + */ +class version_check_exception extends runtime_exception +{ +} diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index b1dcdf10d9..17caaa4a60 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -13,7 +13,7 @@ namespace phpbb; -use phpbb\exception\runtime_exception; +use phpbb\exception\version_check_exception; /** * Class to handle version checking and comparison @@ -172,7 +172,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 runtime_exception + * @throws version_check_exception */ public function get_latest_on_current_branch($force_update = false, $force_cache = false) { @@ -203,7 +203,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 runtime_exception + * @throws version_check_exception */ public function get_suggested_updates($force_update = false, $force_cache = false) { @@ -224,7 +224,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 runtime_exception + * @throws version_check_exception */ public function get_versions_matching_stability($force_update = false, $force_cache = false) { @@ -244,7 +244,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 runtime_exception + * @throws version_check_exception */ public function get_versions($force_update = false, $force_cache = false) { @@ -254,7 +254,7 @@ class version_helper if ($info === false && $force_cache) { - throw new runtime_exception('VERSIONCHECK_FAIL'); + throw new version_check_exception('VERSIONCHECK_FAIL'); } else if ($info === false || $force_update) { @@ -263,7 +263,7 @@ class version_helper if (!empty($error_string)) { - throw new runtime_exception($error_string); + throw new version_check_exception($error_string); } $info = json_decode($info, true); @@ -280,7 +280,7 @@ class version_helper if (empty($info['stable']) && empty($info['unstable'])) { - throw new runtime_exception('VERSIONCHECK_FAIL'); + throw new version_check_exception('VERSIONCHECK_FAIL'); } $info['stable'] = (empty($info['stable'])) ? array() : $info['stable'];