Skip to content

Commit 833217f

Browse files
committed
N°8540 - Maintenance mode
1 parent 5490952 commit 833217f

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

application/startup.inc.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
}
6464
}
6565
});
66-
$oKPI = new ExecutionKPI();
67-
Session::Start();
68-
$oKPI->ComputeAndReport("Session Start");
6966

7067
$sSwitchEnv = utils::ReadParam('switch_env', null);
7168
$bAllowCache = true;

bootstrap.inc.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
*
3131
* @since 3.0.0 N°2214
3232
*/
33+
34+
use Combodo\iTop\Application\Helper\Session;
35+
3336
$bIsValidPhpVersion = false;
3437
if (PHP_MAJOR_VERSION >= 7) {
3538
$bIsValidPhpVersion = true;
@@ -47,17 +50,17 @@
4750

4851
if (!isset($GLOBALS['bBypassAutoload']) || $GLOBALS['bBypassAutoload'] == false) {
4952
require_once APPROOT.'/lib/autoload.php';
53+
$oKPI = new ExecutionKPI();
54+
Session::Start();
55+
$oKPI->ComputeAndReport('Session Start');
56+
57+
// Now bBypassMaintenance mode is set in the session rather than the request params
58+
$bBypassMaintenance = Session::Get('bBypassMaintenance', false);
5059
}
5160

5261
//
5362
// Maintenance mode
5463
//
55-
56-
// Use 'maintenance' parameter to bypass maintenance mode
57-
if (!isset($bBypassMaintenance)) {
58-
$bBypassMaintenance = isset($_REQUEST['maintenance']) ? boolval($_REQUEST['maintenance']) : false;
59-
}
60-
6164
if (file_exists(MAINTENANCE_MODE_FILE) && !$bBypassMaintenance) {
6265
$sTitle = 'Maintenance';
6366
$sMessage = 'This application is currently under maintenance.';

datamodels/2.x/itop-core-update/datamodel.itop-core-update.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<menu id="iTopUpdate" xsi:type="WebPageMenuNode" _delta="define">
55
<rank>60</rank>
66
<parent>SystemTools</parent>
7-
<url>$pages/UI.php?route=core_update.select_update_file&amp;maintenance=true</url>
7+
<url>$pages/UI.php?route=core_update.select_update_file</url>
88
<enable_admin_only>1</enable_admin_only>
99
</menu>
1010
</menus>

datamodels/2.x/itop-core-update/templates/UpdateCoreFiles.ready.js.twig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ var oGetCurrentVersion = {
1515
method: "POST",
1616
url: "{{ sAjaxURL|raw }}",
1717
data: {
18-
route: "core_update_ajax.get_current_version",
19-
maintenance: true
18+
route: "core_update_ajax.get_current_version"
2019
},
2120
dataType: "json",
2221
success: function(data)
@@ -36,8 +35,7 @@ function GetAjaxRequest(sOperation)
3635
url: "{{ sAjaxURL|raw }}",
3736
data: {
3837
route: sOperation,
39-
authent: "{{ sSetupToken }}",
40-
maintenance: true
38+
authent: "{{ sSetupToken }}"
4139
},
4240
dataType: "json"
4341
};

setup/index.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@
2626
* @since 3.0.0 N°3253
2727
*/
2828

29+
use Combodo\iTop\Application\Helper\Session;
30+
2931
require_once('../lib/autoload.php');
3032

33+
// Hack for setup, we need these constants in the session
34+
define('APPROOT', dirname(__DIR__).'/');
35+
define('APPCONF', APPROOT.'conf/');
36+
define('ITOP_DEFAULT_ENV', 'production');
37+
38+
Session::Start();
39+
if (!Session::Get('bBypassMaintenance', false)) {
40+
// Allow setup in maintenance mode
41+
Session::Set('bBypassMaintenance', true);
42+
}
43+
3144
echo <<<HTML
3245
<!DOCTYPE html>
3346
<html>

setup/setuputils.class.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,7 @@ public static function EnterMaintenanceMode($oConfig): bool
19401940
{
19411941
$bPreviousMode = self::IsInMaintenanceMode();
19421942
@touch(MAINTENANCE_MODE_FILE);
1943+
Session::Set('bBypassMaintenance', true);
19431944
SetupLog::Info("----> Entering maintenance mode");
19441945
self::WaitCronTermination($oConfig, "maintenance");
19451946
return $bPreviousMode;
@@ -1948,6 +1949,7 @@ public static function EnterMaintenanceMode($oConfig): bool
19481949
public static function ExitMaintenanceMode($bLog = true)
19491950
{
19501951
@unlink(MAINTENANCE_MODE_FILE);
1952+
Session::Set('bBypassMaintenance', false);
19511953
if ($bLog) {
19521954
SetupLog::Info("<---- Exiting maintenance mode");
19531955
}

sources/Application/Helper/Session.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public static function Start()
3535
}
3636

3737
if (!self::$bIsInitialized) {
38-
SessionHandler::session_set_save_handler();
38+
if (defined('MAINTENANCE_MODE_FILE')) {
39+
// Hack for setup, SessionHandler cannot work under setup
40+
SessionHandler::session_set_save_handler();
41+
}
3942
session_name('itop-'.md5(APPROOT));
4043
}
4144

0 commit comments

Comments
 (0)