[ticket/12610] Correctly handle empty cache

PHPBB3-12610
This commit is contained in:
Tristan Darricau 2016-09-01 16:12:04 +02:00
parent ab58bb8744
commit 57915a8aaa
No known key found for this signature in database
GPG key ID: 817043C2E29DB881
5 changed files with 47 additions and 15 deletions

View file

@ -223,9 +223,9 @@ services:
console.command.update.check: console.command.update.check:
class: phpbb\console\command\update\check class: phpbb\console\command\update\check
arguments: arguments:
- @user - '@user'
- @config - '@config'
- @service_container - '@service_container'
tags: tags:
- { name: console.command } - { name: console.command }

10
phpBB/ext/index.htm Normal file
View file

@ -0,0 +1,10 @@
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>

View file

@ -12,6 +12,7 @@
*/ */
use phpbb\exception\exception_interface; use phpbb\exception\exception_interface;
use phpbb\exception\version_check_exception;
/** /**
* @ignore * @ignore
@ -518,6 +519,10 @@ class acp_extensions
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; $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) catch (exception_interface $e)
{ {
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); $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, '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')); uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table'));

View file

@ -0,0 +1,21 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @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
{
}

View file

@ -13,7 +13,7 @@
namespace phpbb; namespace phpbb;
use phpbb\exception\runtime_exception; use phpbb\exception\version_check_exception;
/** /**
* Class to handle version checking and comparison * 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_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update. * @param bool $force_cache Force the use of the cache. Override $force_update.
* @return string * @return string
* @throws runtime_exception * @throws version_check_exception
*/ */
public function get_latest_on_current_branch($force_update = false, $force_cache = false) 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_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update. * @param bool $force_cache Force the use of the cache. Override $force_update.
* @return string * @return string
* @throws runtime_exception * @throws version_check_exception
*/ */
public function get_suggested_updates($force_update = false, $force_cache = false) 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_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update. * @param bool $force_cache Force the use of the cache. Override $force_update.
* @return string Version info * @return string Version info
* @throws runtime_exception * @throws version_check_exception
*/ */
public function get_versions_matching_stability($force_update = false, $force_cache = false) 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_update Ignores cached data. Defaults to false.
* @param bool $force_cache Force the use of the cache. Override $force_update. * @param bool $force_cache Force the use of the cache. Override $force_update.
* @return string Version info, includes stable and unstable data * @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) public function get_versions($force_update = false, $force_cache = false)
{ {
@ -254,7 +254,7 @@ class version_helper
if ($info === false && $force_cache) if ($info === false && $force_cache)
{ {
throw new runtime_exception('VERSIONCHECK_FAIL'); throw new version_check_exception('VERSIONCHECK_FAIL');
} }
else if ($info === false || $force_update) else if ($info === false || $force_update)
{ {
@ -263,7 +263,7 @@ class version_helper
if (!empty($error_string)) if (!empty($error_string))
{ {
throw new runtime_exception($error_string); throw new version_check_exception($error_string);
} }
$info = json_decode($info, true); $info = json_decode($info, true);
@ -280,7 +280,7 @@ class version_helper
if (empty($info['stable']) && empty($info['unstable'])) 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']; $info['stable'] = (empty($info['stable'])) ? array() : $info['stable'];