mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 17:23:04 +02:00
fixes #1040 move check upgrade action to maintenance page
This commit is contained in:
@@ -186,6 +186,58 @@ DELETE
|
||||
clear_derivative_cache($_GET['type']);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'check_upgrade':
|
||||
{
|
||||
if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
|
||||
{
|
||||
$page['errors'][] = l10n('Unable to check for upgrade.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$versions = array('current' => PHPWG_VERSION);
|
||||
$lines = @explode("\r\n", $result);
|
||||
|
||||
// if the current version is a BSF (development branch) build, we check
|
||||
// the first line, for stable versions, we check the second line
|
||||
if (preg_match('/^BSF/', $versions['current']))
|
||||
{
|
||||
$versions['latest'] = trim($lines[0]);
|
||||
|
||||
// because integer are limited to 4,294,967,296 we need to split BSF
|
||||
// versions in date.time
|
||||
foreach ($versions as $key => $value)
|
||||
{
|
||||
$versions[$key] =
|
||||
preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$versions['latest'] = trim($lines[1]);
|
||||
}
|
||||
|
||||
if ('' == $versions['latest'])
|
||||
{
|
||||
$page['errors'][] = l10n('Check for upgrade failed for unknown reasons.');
|
||||
}
|
||||
// concatenation needed to avoid automatic transformation by release
|
||||
// script generator
|
||||
else if ('%'.'PWGVERSION'.'%' == $versions['current'])
|
||||
{
|
||||
$page['infos'][] = l10n('You are running on development sources, no check possible.');
|
||||
}
|
||||
else if (version_compare($versions['current'], $versions['latest']) < 0)
|
||||
{
|
||||
$page['infos'][] = l10n('A new version of Piwigo is available.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$page['infos'][] = l10n('You are running the latest version of Piwigo.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default :
|
||||
{
|
||||
break;
|
||||
@@ -232,6 +284,7 @@ $template->assign(
|
||||
|
||||
'PHPWG_URL' => PHPWG_URL,
|
||||
'PWG_VERSION' => PHPWG_VERSION,
|
||||
'U_CHECK_UPGRADE' => sprintf($url_format, 'check_upgrade'),
|
||||
'OS' => PHP_OS,
|
||||
'PHP_VERSION' => phpversion(),
|
||||
'DB_ENGINE' => 'MySQL',
|
||||
|
||||
Reference in New Issue
Block a user