fixes #583 check PHP version requirement before update

* piwigo.org can now tell Piwigo which version of PHP is required for each version of Piwigo. If the installed version of PHP is too old, do not let the user update.
* slight visual enhancements on the update page
This commit is contained in:
plegall
2020-11-04 17:38:09 +01:00
parent f09e3e7c0a
commit d651fe38cd
5 changed files with 131 additions and 28 deletions
+35 -10
View File
@@ -27,25 +27,17 @@ check_input_parameter('to', $_GET, false, '/^\d+\.\d+\.\d+$/');
$upgrade_to = isset($_GET['to']) ? $_GET['to'] : '';
$updates = new updates();
$new_versions = $updates->get_piwigo_new_versions();
// +-----------------------------------------------------------------------+
// | Step 0 |
// +-----------------------------------------------------------------------+
if ($step == 0)
{
$new_versions = $updates->get_piwigo_new_versions();
if (isset($new_versions['minor']) and isset($new_versions['major']))
{
$step = 1;
$upgrade_to = $new_versions['major'];
$template->assign(
array(
'MINOR_VERSION' => $new_versions['minor'],
'MAJOR_VERSION' => $new_versions['major'],
)
);
}
elseif (isset($new_versions['minor']))
{
@@ -96,6 +88,20 @@ if ($step == 3 and is_webmaster())
$template->assign('missing', $updates->missing);
}
// +-----------------------------------------------------------------------+
// | Check for requirements |
// +-----------------------------------------------------------------------+
if (isset($new_versions['minor_php']) and version_compare(phpversion(), $new_versions['minor_php'], '<'))
{
$template->assign('MINOR_RELEASE_PHP_REQUIRED', $new_versions['minor_php']);
}
if (isset($new_versions['major_php']) and version_compare(phpversion(), $new_versions['major_php'], '<'))
{
$template->assign('MAJOR_RELEASE_PHP_REQUIRED', $new_versions['major_php']);
}
// +-----------------------------------------------------------------------+
// | Process template |
// +-----------------------------------------------------------------------+
@@ -109,10 +115,29 @@ $template->assign(array(
'STEP' => $step,
'PHPWG_VERSION' => PHPWG_VERSION,
'UPGRADE_TO' => $upgrade_to,
'RELEASE_URL' => PHPWG_URL.'/releases/'.$upgrade_to,
)
);
if (isset($new_versions['minor']))
{
$template->assign(
array(
'MINOR_VERSION' => $new_versions['minor'],
'MINOR_RELEASE_URL' => PHPWG_URL.'/releases/'.$new_versions['minor'],
)
);
}
if (isset($new_versions['major']))
{
$template->assign(
array(
'MAJOR_VERSION' => $new_versions['major'],
'MAJOR_RELEASE_URL' => PHPWG_URL.'/releases/'.$new_versions['major'],
)
);
}
$template->set_filename('plugin_admin_content', 'updates_pwg.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');