Full restore: after an error maintenance mode stays on, with the one line to switch it off and run again; maintenance that was on before stays on
This commit is contained in:
@@ -87,7 +87,7 @@ final class RestoreFullService {
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array{dbReport:array, dataFiles:int, configKeys:int, dbConsistent:bool, missingApps:list<string>} */
|
||||
/** @return array{dbReport:array, dataFiles:int, configKeys:int, dbConsistent:bool, missingApps:list<string>, maintenanceLeftOn:bool} */
|
||||
public function restoreFull(Target $target, string $snapshotId, bool $skipMissingTables = false): array {
|
||||
$check = $this->checkCompatibility($target, $snapshotId, $skipMissingTables);
|
||||
if (!$check['ok']) {
|
||||
@@ -96,18 +96,17 @@ final class RestoreFullService {
|
||||
// Maintenance mode for the whole restore: background jobs (cron.php stops in maintenance
|
||||
// mode), page visits (AJAX cron) and users must not write into tables or the data
|
||||
// directory while they are being replaced; a row written in between would collide with a
|
||||
// restored one or be silently lost. Switched off again at the end, also after an error:
|
||||
// occ only offers app commands outside maintenance mode, and the guide's next step is
|
||||
// to run the same restore again with --force.
|
||||
// restored one or be silently lost. Switched off after a restore that completed. After an
|
||||
// error it stays on: the instance may be partly restored, and must not be used like that.
|
||||
// occ only offers app commands outside maintenance mode, so the admin switches it off
|
||||
// right before running the restore again (see RestoreFull). Already on before: left on.
|
||||
$wasInMaintenance = $this->config->getSystemValueBool('maintenance', false);
|
||||
$this->config->setSystemValue('maintenance', true);
|
||||
try {
|
||||
return $this->restoreInMaintenance($target, $snapshotId, $skipMissingTables, $check);
|
||||
} finally {
|
||||
if (!$wasInMaintenance) {
|
||||
$this->config->setSystemValue('maintenance', false);
|
||||
}
|
||||
$result = $this->restoreInMaintenance($target, $snapshotId, $skipMissingTables, $check);
|
||||
if (!$wasInMaintenance) {
|
||||
$this->config->setSystemValue('maintenance', false);
|
||||
}
|
||||
return $result + ['maintenanceLeftOn' => $wasInMaintenance];
|
||||
}
|
||||
|
||||
/** @return array{dbReport:array, dataFiles:int, configKeys:int, dbConsistent:bool, missingApps:list<string>} */
|
||||
|
||||
Reference in New Issue
Block a user