Skip to content

Commit

Permalink
N°4227 / N°4225 - Enhance SetupUtils interface
Browse files Browse the repository at this point in the history
  • Loading branch information
eespie committed Sep 6, 2021
1 parent 095c975 commit 8e0ae67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions datamodels/2.x/itop-backup/dbrestore.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public function RestoreFromCompressedBackup($sFile, $sEnvironment = 'production'

try {
IssueLog::Info('Backup Restore - LOCK acquired, executing...');
$bReadonlyBefore = SetupUtils::IsInReadOnlyMode();
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
$bReadonlyBefore = SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());

try {
//safe zone for db backup => cron is stopped/ itop in readonly
Expand Down
3 changes: 1 addition & 2 deletions setup/backup.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ public function MakeName($sNameSpec = "__DB__-%Y-%m-%d")
*/
public function CreateCompressedBackup($sTargetFile, $sSourceConfigFile = null)
{
$bReadonlyBefore = SetupUtils::IsInReadOnlyMode();
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
$bReadonlyBefore = SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
try {
//safe zone for db backup => cron is stopped/ itop in readonly
$bIsCmdbSourceInitialized = CMDBSource::GetMysqli() instanceof mysqli;
Expand Down
8 changes: 6 additions & 2 deletions setup/setuputils.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1988,11 +1988,13 @@ public static function GetSetupQueriesFilePath()
return APPROOT.'log/setup-queries-'.strftime('%Y-%m-%d_%H_%M').'.sql';
}

public static function EnterMaintenanceMode($oConfig)
public static function EnterMaintenanceMode($oConfig): bool
{
$bPreviousMode = self::IsInMaintenanceMode();
@touch(MAINTENANCE_MODE_FILE);
self::Log("----> Entering maintenance mode");
self::WaitCronTermination($oConfig, "maintenance");
return $bPreviousMode;
}

public static function ExitMaintenanceMode($bLog = true)
Expand All @@ -2009,11 +2011,13 @@ public static function IsInMaintenanceMode()
return file_exists(MAINTENANCE_MODE_FILE);
}

public static function EnterReadOnlyMode($oConfig)
public static function EnterReadOnlyMode($oConfig): bool
{
$bPreviousMode = self::IsInReadOnlyMode();
@touch(READONLY_MODE_FILE);
self::Log("----> Entering read only mode");
self::WaitCronTermination($oConfig, "read only");
return $bPreviousMode;
}

public static function ExitReadOnlyMode($bLog = true)
Expand Down

0 comments on commit 8e0ae67

Please sign in to comment.