mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Merge remote-tracking branch 'EXreaction/ticket/9871-2' into develop
* EXreaction/ticket/9871-2: [ticket/9871] Can set current version to use instead of the phpBB version [ticket/9871] Fix indentation on comment [ticket/9871] Fix test name [ticket/9871] Split fast and slow version tests [ticket/9871] Option to force the stability when checking for updates [ticket/9871] Allow setting the host/file to load for the version class [ticket/9871] Restore get_remote_file_test [ticket/9871] Fix tests [ticket/9871] Typehint and comment on var types [ticket/9871] Mark test as slow [ticket/9871] Restore phpbb_version_compare [ticket/9871] Restore get_remote_file [ticket/9871] Use $request->variable instead of request_var [ticket/9871] Update version check file to use json format
This commit is contained in:
@@ -25,7 +25,7 @@ class acp_main
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $cache, $user, $auth, $template, $request;
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;
|
||||
|
||||
// Show restore permissions notice
|
||||
if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm'))
|
||||
@@ -432,17 +432,19 @@ class acp_main
|
||||
));
|
||||
}
|
||||
|
||||
$latest_version_info = false;
|
||||
if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false)
|
||||
$version_helper = $phpbb_container->get('version_helper');
|
||||
try
|
||||
{
|
||||
$template->assign_var('S_VERSIONCHECK_FAIL', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$latest_version_info = explode("\n", $latest_version_info);
|
||||
$recheck = $request->variable('versioncheck_force', false);
|
||||
$updates_available = $version_helper->get_suggested_updates($recheck);
|
||||
|
||||
$template->assign_var('S_VERSION_UP_TO_DATE', empty($updates_available));
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_VERSION_UP_TO_DATE' => phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='),
|
||||
'S_VERSIONCHECK_FAIL' => true,
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -24,64 +24,42 @@ class acp_update
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $user, $auth, $template, $cache;
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
global $config, $user, $template, $request;
|
||||
global $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$user->add_lang('install');
|
||||
|
||||
$this->tpl_name = 'acp_update';
|
||||
$this->page_title = 'ACP_VERSION_CHECK';
|
||||
|
||||
// Get current and latest version
|
||||
$errstr = '';
|
||||
$errno = 0;
|
||||
|
||||
$info = obtain_latest_version_info(request_var('versioncheck_force', false));
|
||||
|
||||
if (empty($info))
|
||||
$version_helper = $phpbb_container->get('version_helper');
|
||||
try
|
||||
{
|
||||
trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING);
|
||||
$recheck = $request->variable('versioncheck_force', false);
|
||||
$updates_available = $version_helper->get_suggested_updates($recheck);
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$template->assign_var('S_VERSIONCHECK_FAIL', true);
|
||||
|
||||
$updates_available = array();
|
||||
}
|
||||
|
||||
$info = explode("\n", $info);
|
||||
$latest_version = trim($info[0]);
|
||||
foreach ($updates_available as $branch => $version_data)
|
||||
{
|
||||
$template->assign_block_vars('updates_available', $version_data);
|
||||
}
|
||||
|
||||
$announcement_url = trim($info[1]);
|
||||
$announcement_url = (strpos($announcement_url, '&') === false) ? str_replace('&', '&', $announcement_url) : $announcement_url;
|
||||
$update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update');
|
||||
|
||||
// next feature release
|
||||
$next_feature_version = $next_feature_announcement_url = false;
|
||||
if (isset($info[2]) && trim($info[2]) !== '')
|
||||
{
|
||||
$next_feature_version = trim($info[2]);
|
||||
$next_feature_announcement_url = trim($info[3]);
|
||||
}
|
||||
|
||||
// Determine automatic update...
|
||||
$sql = 'SELECT config_value
|
||||
FROM ' . CONFIG_TABLE . "
|
||||
WHERE config_name = 'version_update_from'";
|
||||
$result = $db->sql_query($sql);
|
||||
$version_update_from = (string) $db->sql_fetchfield('config_value');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$current_version = (!empty($version_update_from)) ? $version_update_from : $config['version'];
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='),
|
||||
'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='),
|
||||
'S_VERSION_CHECK' => true,
|
||||
'U_ACTION' => $this->u_action,
|
||||
'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'),
|
||||
'S_UP_TO_DATE' => empty($updates_available),
|
||||
'U_ACTION' => $this->u_action,
|
||||
'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'),
|
||||
|
||||
'LATEST_VERSION' => $latest_version,
|
||||
'CURRENT_VERSION' => $config['version'],
|
||||
'AUTO_VERSION' => $version_update_from,
|
||||
'NEXT_FEATURE_VERSION' => $next_feature_version,
|
||||
'CURRENT_VERSION' => $config['version'],
|
||||
|
||||
'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link),
|
||||
'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false,
|
||||
'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $update_link),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -3041,7 +3041,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Tidy Warnings
|
||||
* Remove all warnings which have now expired from the database
|
||||
* The duration of a warning can be defined by the administrator
|
||||
@@ -3150,45 +3150,6 @@ function add_permission_language()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the latest version information
|
||||
*
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false.
|
||||
* @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
|
||||
*
|
||||
* @return string | false Version info on success, false on failure.
|
||||
*/
|
||||
function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
$info = $cache->get('versioncheck');
|
||||
|
||||
if ($info === false || $force_update)
|
||||
{
|
||||
$errstr = '';
|
||||
$errno = 0;
|
||||
|
||||
$info = get_remote_file('version.phpbb.com', '/phpbb',
|
||||
((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
|
||||
|
||||
if (empty($info))
|
||||
{
|
||||
$cache->destroy('versioncheck');
|
||||
if ($warn_fail)
|
||||
{
|
||||
trigger_error($errstr, E_USER_WARNING);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$cache->put('versioncheck', $info, $ttl);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a particular flag in a bitfield column of a given table.
|
||||
*
|
||||
|
Reference in New Issue
Block a user