Compare commits

...

2 Commits

Author SHA1 Message Date
Eric Espie
daee4811e8 N°8540 - Maintenance mode (fix after review) 2026-02-19 10:56:13 +01:00
Eric Espie
833217f467 N°8540 - Maintenance mode 2026-02-18 16:13:26 +01:00
7 changed files with 33 additions and 16 deletions

View File

@@ -63,9 +63,6 @@ register_shutdown_function(function () {
}
}
});
$oKPI = new ExecutionKPI();
Session::Start();
$oKPI->ComputeAndReport("Session Start");
$sSwitchEnv = utils::ReadParam('switch_env', null);
$bAllowCache = true;

View File

@@ -30,6 +30,9 @@
*
* @since 3.0.0 N°2214
*/
use Combodo\iTop\Application\Helper\Session;
$bIsValidPhpVersion = false;
if (PHP_MAJOR_VERSION >= 7) {
$bIsValidPhpVersion = true;
@@ -44,20 +47,21 @@ define('READONLY_MODE_FILE', APPROOT.'data/.readonly');
$fItopStarted = microtime(true);
$iItopInitialMemory = memory_get_usage(true);
$bBypassMaintenance = false;
if (!isset($GLOBALS['bBypassAutoload']) || $GLOBALS['bBypassAutoload'] == false) {
require_once APPROOT.'/lib/autoload.php';
// Start the session here to read the "bBypassMaintenance" param
$oKPI = new ExecutionKPI();
Session::Start();
$oKPI->ComputeAndReport('Session Start');
// Now bBypassMaintenance mode is set in the session rather than the request params
$bBypassMaintenance = Session::Get('bBypassMaintenance', false);
}
//
// Maintenance mode
//
// Use 'maintenance' parameter to bypass maintenance mode
if (!isset($bBypassMaintenance)) {
$bBypassMaintenance = isset($_REQUEST['maintenance']) ? boolval($_REQUEST['maintenance']) : false;
}
if (file_exists(MAINTENANCE_MODE_FILE) && !$bBypassMaintenance) {
$sTitle = 'Maintenance';
$sMessage = 'This application is currently under maintenance.';

View File

@@ -4,7 +4,7 @@
<menu id="iTopUpdate" xsi:type="WebPageMenuNode" _delta="define">
<rank>60</rank>
<parent>SystemTools</parent>
<url>$pages/UI.php?route=core_update.select_update_file&amp;maintenance=true</url>
<url>$pages/UI.php?route=core_update.select_update_file</url>
<enable_admin_only>1</enable_admin_only>
</menu>
</menus>

View File

@@ -15,8 +15,7 @@ var oGetCurrentVersion = {
method: "POST",
url: "{{ sAjaxURL|raw }}",
data: {
route: "core_update_ajax.get_current_version",
maintenance: true
route: "core_update_ajax.get_current_version"
},
dataType: "json",
success: function(data)
@@ -36,8 +35,7 @@ function GetAjaxRequest(sOperation)
url: "{{ sAjaxURL|raw }}",
data: {
route: sOperation,
authent: "{{ sSetupToken }}",
maintenance: true
authent: "{{ sSetupToken }}"
},
dataType: "json"
};

View File

@@ -26,8 +26,21 @@
* @since 3.0.0 N°3253
*/
use Combodo\iTop\Application\Helper\Session;
require_once('../lib/autoload.php');
// Hack for setup, we need these constants in the session
define('APPROOT', dirname(__DIR__).'/');
define('APPCONF', APPROOT.'conf/');
define('ITOP_DEFAULT_ENV', 'production');
Session::Start();
if (!Session::Get('bBypassMaintenance', false)) {
// Allow setup in maintenance mode
Session::Set('bBypassMaintenance', true);
}
echo <<<HTML
<!DOCTYPE html>
<html>

View File

@@ -1940,6 +1940,7 @@ JS
{
$bPreviousMode = self::IsInMaintenanceMode();
@touch(MAINTENANCE_MODE_FILE);
Session::Set('bBypassMaintenance', true);
SetupLog::Info("----> Entering maintenance mode");
self::WaitCronTermination($oConfig, "maintenance");
return $bPreviousMode;
@@ -1948,6 +1949,7 @@ JS
public static function ExitMaintenanceMode($bLog = true)
{
@unlink(MAINTENANCE_MODE_FILE);
Session::Set('bBypassMaintenance', false);
if ($bLog) {
SetupLog::Info("<---- Exiting maintenance mode");
}

View File

@@ -35,7 +35,10 @@ class Session
}
if (!self::$bIsInitialized) {
SessionHandler::session_set_save_handler();
if (defined('MAINTENANCE_MODE_FILE')) {
// Hack for setup, SessionHandler cannot work under setup
SessionHandler::session_set_save_handler();
}
session_name('itop-'.md5(APPROOT));
}