1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-09 17:15:19 +02:00

[ticket/11366] Force the use of the cache on the list page

PHPBB3-11366
This commit is contained in:
Tristan Darricau 2014-05-12 12:30:27 +02:00
parent 64467f50db
commit 521fe2b8e2
3 changed files with 53 additions and 38 deletions

View File

@ -26,7 +26,9 @@
<td><strong>{enabled.META_DISPLAY_NAME}</strong></td> <td><strong>{enabled.META_DISPLAY_NAME}</strong></td>
<td style="text-align: center;"> <td style="text-align: center;">
<!-- IF enabled.S_VERSIONCHECK --> <!-- IF enabled.S_VERSIONCHECK -->
<strong <!-- IF enabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{enabled.META_VERSION}</strong> [&nbsp;<a href="{enabled.U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE}</a>&nbsp;] <strong <!-- IF enabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{enabled.META_VERSION}</strong>
<!-- ELSE -->
{enabled.META_VERSION}
<!-- ENDIF --> <!-- ENDIF -->
</td> </td>
<td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td> <td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td>
@ -49,7 +51,9 @@
<td><strong>{disabled.META_DISPLAY_NAME}</strong></td> <td><strong>{disabled.META_DISPLAY_NAME}</strong></td>
<td style="text-align: center;"> <td style="text-align: center;">
<!-- IF disabled.S_VERSIONCHECK --> <!-- IF disabled.S_VERSIONCHECK -->
<strong <!-- IF disabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{disabled.META_VERSION}</strong> [&nbsp;<a href="{disabled.U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE}</a>&nbsp;] <strong <!-- IF disabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{disabled.META_VERSION}</strong>
<!-- ELSE -->
{disabled.META_VERSION}
<!-- ENDIF --> <!-- ENDIF -->
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">

View File

@ -29,6 +29,7 @@ class acp_extensions
private $user; private $user;
private $cache; private $cache;
private $log; private $log;
private $request;
function main() function main()
{ {
@ -40,6 +41,7 @@ class acp_extensions
$this->template = $template; $this->template = $template;
$this->user = $user; $this->user = $user;
$this->cache = $cache; $this->cache = $cache;
$this->request = $request;
$this->log = $phpbb_log; $this->log = $phpbb_log;
$user->add_lang(array('install', 'acp/extensions', 'migrator')); $user->add_lang(array('install', 'acp/extensions', 'migrator'));
@ -304,7 +306,7 @@ class acp_extensions
'META_VERSION' => $meta['version'], 'META_VERSION' => $meta['version'],
); );
$updates = $this->version_check($md_manager); $updates = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false));
$enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); $enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
@ -359,7 +361,7 @@ class acp_extensions
'META_VERSION' => $meta['version'], 'META_VERSION' => $meta['version'],
); );
$updates = $this->version_check($md_manager); $updates = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false));
$disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); $disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
@ -417,7 +419,7 @@ class acp_extensions
'META_VERSION' => $meta['version'], 'META_VERSION' => $meta['version'],
); );
$updates = $this->version_check($md_manager); $updates = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false));
$available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true; $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
@ -490,8 +492,9 @@ class acp_extensions
$version_helper = new \phpbb\version_helper($this->cache, $this->config, $this->user); $version_helper = new \phpbb\version_helper($this->cache, $this->config, $this->user);
$version_helper->set_current_version($meta['version']); $version_helper->set_current_version($meta['version']);
$version_helper->set_file_location($version_check ['host'], $version_check ['directory'], $version_check ['filename']); $version_helper->set_file_location($version_check ['host'], $version_check ['directory'], $version_check ['filename']);
$version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
return $updates = $version_helper->get_suggested_updates($force); return $updates = $version_helper->get_suggested_updates($force, true);
} }
/** /**

View File

@ -161,12 +161,13 @@ class version_helper
* Gets the latest version for the current branch the user is on * Gets the latest version for the current branch the user is on
* *
* @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.
* @return string * @return string
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function get_latest_on_current_branch($force_update = false) public function get_latest_on_current_branch($force_update = false, $force_cache = false)
{ {
$versions = $this->get_versions_matching_stability($force_update); $versions = $this->get_versions_matching_stability($force_update, $force_cache);
$self = $this; $self = $this;
$current_version = $this->current_version; $current_version = $this->current_version;
@ -191,12 +192,13 @@ class version_helper
* Obtains the latest version information * Obtains the latest version information
* *
* @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.
* @return string * @return string
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function get_suggested_updates($force_update = false) public function get_suggested_updates($force_update = false, $force_cache = false)
{ {
$versions = $this->get_versions_matching_stability($force_update); $versions = $this->get_versions_matching_stability($force_update, $force_cache);
$self = $this; $self = $this;
$current_version = $this->current_version; $current_version = $this->current_version;
@ -211,12 +213,13 @@ class version_helper
* Obtains the latest version information matching the stability of the current install * Obtains the latest version information matching the stability of the current install
* *
* @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.
* @return string Version info * @return string Version info
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function get_versions_matching_stability($force_update = false) public function get_versions_matching_stability($force_update = false, $force_cache = false)
{ {
$info = $this->get_versions($force_update); $info = $this->get_versions($force_update, $force_cache);
if ($this->force_stability !== null) if ($this->force_stability !== null)
{ {
@ -230,16 +233,21 @@ class version_helper
* Obtains the latest version information * Obtains the latest version information
* *
* @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.
* @return string Version info, includes stable and unstable data * @return string Version info, includes stable and unstable data
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function get_versions($force_update = false) public function get_versions($force_update = false, $force_cache = false)
{ {
$cache_file = 'versioncheck_' . $this->host . $this->path . $this->file; $cache_file = 'versioncheck_' . $this->host . $this->path . $this->file;
$info = $this->cache->get($cache_file); $info = $this->cache->get($cache_file);
if ($info === false || $force_update) if ($info === false && $force_cache)
{
throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
}
else if ($info === false || $force_update)
{ {
$errstr = $errno = ''; $errstr = $errno = '';
$info = get_remote_file($this->host, $this->path, $this->file, $errstr, $errno); $info = get_remote_file($this->host, $this->path, $this->file, $errstr, $errno);