Compare commits

...

3 Commits

3 changed files with 37 additions and 11 deletions

View File

@@ -81,13 +81,13 @@ class ApplicationInstallSequencer extends StepSequencer
return $this->ComputeNextStep($sStep);
case 'log-parameters':
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep($sStep)) {
$this->DoLogParameters();
}
return $this->ComputeNextStep($sStep);
case 'backup':
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep($sStep, false)) {
$aBackupOptions = $this->oParams->Get('optional_steps')['backup'];
// __DB__-%Y-%m-%d
$sDestination = $aBackupOptions['destination'];
@@ -100,7 +100,7 @@ class ApplicationInstallSequencer extends StepSequencer
case 'migrate-before':
$this->oRunTimeEnvironment->EnterMaintenanceMode($this->GetConfig());
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep($sStep)) {
$this->oRunTimeEnvironment->MigrateDataBeforeUpdateStructure($this->oParams->Get('mode'), $this->GetConfig());
}
return $this->ComputeNextStep($sStep);
@@ -111,7 +111,7 @@ class ApplicationInstallSequencer extends StepSequencer
return $this->ComputeNextStep($sStep);
case 'migrate-after':
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep($sStep)) {
$this->oRunTimeEnvironment->MigrateDataAfterUpdateStructure($this->oParams->Get('mode'), $this->GetConfig());
}
return $this->ComputeNextStep($sStep);
@@ -191,13 +191,17 @@ class ApplicationInstallSequencer extends StepSequencer
public function GetStepNames(): array
{
$aStepNames = [ ''];
foreach (['log-parameters', 'backup', 'migrate-before'] as $sStepName) {
if (array_key_exists($sStepName, $this->oParams->Get('optional_steps', []))) {
$aStepNames [] = $sStepName;
}
if ($this->HasOptionalStep('log-parameters')) {
$aStepNames [] = 'log-parameters';
}
if ($this->HasOptionalStep('backup', false)) {
$aStepNames [] = 'backup';
}
if ($this->HasOptionalStep('migrate-before')) {
$aStepNames [] = 'migrate-before';
}
$aStepNames [] = 'db-schema';
if (array_key_exists('migrate-after', $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep('migrate-after')) {
$aStepNames [] = 'migrate-after';
}

View File

@@ -102,7 +102,7 @@ class DataAuditSequencer extends StepSequencer
protected function IsDataAuditRequired(): bool
{
if (! array_key_exists('setup-audit', $this->oParams->Get('optional_steps', []))) {
if (!$this->HasOptionalStep('setup-audit', false)) {
return false;
}
@@ -124,7 +124,7 @@ class DataAuditSequencer extends StepSequencer
public function GetStepNames(): array
{
$aStepNames = [''];
if (array_key_exists('copy', $this->oParams->Get('optional_steps', []))) {
if ($this->HasOptionalStep('copy')) {
$aStepNames[] = 'copy';
}
$aStepNames[] = 'compile';

View File

@@ -233,4 +233,26 @@ abstract class StepSequencer
* @return array (status => , message => , percentage-completed => , next-step => , next-step-label => )
*/
abstract public function ExecuteStep($sStep = '', $sInstallComment = null): array;
/**
* Check whether an optional step is enabled in the "optional_steps" parameters. If optional_steps is not set, use $bDefaultValue as its default value
*
* @param $sStep
* @param bool $bDefaultValue
*
* @return bool
* @throws \Exception
*/
protected function HasOptionalStep($sStep, bool $bDefaultValue = true)
{
$aOptionalSteps = $this->oParams->Get('optional_steps', null);
if (is_null($aOptionalSteps)) {
return $bDefaultValue;
}
if (is_array($aOptionalSteps)) {
return array_key_exists($sStep, $aOptionalSteps);
}
throw new Exception('Incorrect value for parameter optional_steps');
}
}