fully migrate admin_updates; removed unused Froxlor\UI\Paging;

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-18 16:11:56 +01:00
parent 69895943bd
commit c1f4ee4e05
11 changed files with 144 additions and 592 deletions

View File

@@ -18,27 +18,24 @@
/**
* Function showUpdateStep
*
* outputs and logs the current
* update progress
* stores and logs the current update progress
*
* @param
* string task/status
* @param
* bool needs_status (if false, a linebreak will be added)
* @param string $task
* @param bool $needs_status (if false, a linebreak will be added)
*
* @return string formatted output and log-entry
* @return void
*/
function showUpdateStep($task = null, $needs_status = true)
{
global $update_tasks, $task_counter;
set_time_limit(30);
if (! $needs_status)
echo "<b>";
// output
echo $task;
$update_tasks[$task_counter] = ['title' => $task, 'result' => 0];
if (! $needs_status) {
echo "</b><br />";
if (!$needs_status) {
$task_counter++;
}
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
@@ -47,40 +44,39 @@ function showUpdateStep($task = null, $needs_status = true)
/**
* Function lastStepStatus
*
* outputs [OK] (success), [??] (warning) or [!!] (failure)
* of the last update-step
* outputs status of the last update-step
*
* @param
* int status (0 = success, 1 = warning, 2 = failure)
* @param int $status (0 = success, 1 = warning, 2 = failure)
* @param string $message
* @param string $additional_info
*
* @return string formatted output and log-entry
*/
function lastStepStatus($status = -1, $message = '')
function lastStepStatus(int $status = -1, string $message = '', string $additional_info = '')
{
global $update_tasks, $task_counter;
$update_tasks[$task_counter]['result_txt'] = $message ?? 'OK';
$update_tasks[$task_counter]['result_desc'] = $additional_info ?? '';
switch ($status) {
case 0:
$status_sign = ($message != '') ? '[' . $message . ']' : '[OK]';
$status_color = 'ok';
break;
case 1:
$status_sign = ($message != '') ? '[' . $message . ']' : '[??]';
$status_color = 'warn';
$update_tasks[$task_counter]['result'] = 2;
break;
case 2:
$status_sign = ($message != '') ? '[' . $message . ']' : '[!!]';
$status_color = 'err';
$update_tasks[$task_counter]['result'] = 1;
break;
default:
$status_sign = '[unknown]';
$status_color = 'unknown';
$update_tasks[$task_counter]['result'] = -1;
break;
}
// output
echo "<span class=\"update-step update-step-" . $status_color . "\">" . $status_sign . "</span><br />";
$task_counter++;
if ($status == - 1 || $status == 2) {
if ($status == -1 || $status == 2) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
} elseif ($status == 0 || $status == 1) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success');

View File

@@ -62,8 +62,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
// none of the files existed
lastStepStatus(0);
} else {
lastStepStatus(1, 'manual commands needed');
echo '<span class="update-step update-step-err">Please run the following commands manually:</span><br><pre>' . $del_list . '</pre><br>';
lastStepStatus(1, 'manual commands needed', 'Please run the following commands manually:<br><pre>' . $del_list . '</pre>');
}
}
}

View File

@@ -553,7 +553,6 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
$has_preconfig = true;
$description = 'The template-variable {PASSWORD} has been replaced with {LINK}. Please update your password reset templates!';
$return['update_template_var_password_changed_note'] = ['type' => 'infotext', 'value' => $description];
eval("\$return.=\"" . \Froxlor\UI\Template::getTemplate("update/preconfigitem") . "\";");
}
if (versionInUpdate($current_version, '0.9.31-dev5')) {

View File

@@ -16,12 +16,13 @@
* @package Install
*
*/
use Froxlor\FroxlorLogger;
require_once __DIR__ . '/lib/updateFunctions.php';
if (! defined('_CRON_UPDATE')) {
if (! defined('AREA') || (defined('AREA') && AREA != 'admin') || ! isset($userinfo['loginname']) || (isset($userinfo['loginname']) && $userinfo['loginname'] == '')) {
if (!defined('_CRON_UPDATE')) {
if (!defined('AREA') || (defined('AREA') && AREA != 'admin') || !isset($userinfo['loginname']) || (isset($userinfo['loginname']) && $userinfo['loginname'] == '')) {
header('Location: ../index.php');
exit();
}
@@ -40,18 +41,24 @@ try {
}
if (\Froxlor\Froxlor::isFroxlor()) {
include_once (\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.9/update_0.9.inc.php'));
include_once (\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.10/update_0.10.inc.php'));
// will be filled and increased by the update include-files below
$update_tasks = [];
$task_counter = 0;
include_once(\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.9/update_0.9.inc.php'));
include_once(\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.10/update_0.10.inc.php'));
include_once(\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.11/update_0.11.inc.php'));
// Check Froxlor - database integrity (only happens after all updates are done, so we know the db-layout is okay)
showUpdateStep("Checking database integrity");
$integrity = new \Froxlor\Database\IntegrityCheck();
if (! $integrity->checkAll()) {
if (!$integrity->checkAll()) {
lastStepStatus(1, 'Monkeys ate the integrity');
showUpdateStep("Trying to remove monkeys, feeding bananas");
if (! $integrity->fixAll()) {
lastStepStatus(2, 'Some monkeys just would not move, you should contact team@froxlor.org');
if (!$integrity->fixAll()) {
lastStepStatus(2, 'failed', 'Some monkeys just would not move, you should contact team@froxlor.org');
} else {
lastStepStatus(0, 'Integrity restored');
}