'Copying data model files', 'compile' => 'Compiling the data model', 'setup-audit' => 'Checking data consistency with the new data model', 'complete' => 'Check Completed', ]; protected const SUCCESS_LABELS = [ 'copy' => 'Data model files copied', 'compile' => 'Data model compilation completed', 'setup-audit' => 'Data consistency check completed', 'complete' => 'All checks completed', ]; /** * @inherit */ public function ExecuteStep($sStep = '', $sInstallComment = null): array { $fStart = microtime(true); try { /** * @since 3.2.0 move the ContextTag init at the very beginning of the method * @noinspection PhpUnusedLocalVariableInspection */ $oContextTag = new ContextTag(ContextTag::TAG_SETUP); SetupLog::Info("##### STEP {$sStep} start"); switch ($sStep) { case '': return $this->ComputeNextStep($sStep); case 'copy': $this->oRunTimeEnvironment->CopySetupFiles(); return $this->ComputeNextStep($sStep); case 'compile': $aSelectedModules = $this->oParams->Get('selected_modules', []); $sSourceDir = $this->oParams->Get('source_dir', 'datamodels/latest'); $sExtensionDir = $this->oParams->Get('extensions_dir', 'extensions'); $aRemovedExtensionCodes = $this->oParams->Get('removed_extensions', []); $bUseSymbolicLinks = $this->oParams->Get('use_symbolic_links', null) === 'on'; MetaModel::ResetAllCaches($this->oRunTimeEnvironment->GetBuildEnv()); $this->oRunTimeEnvironment->DoCompile( $aRemovedExtensionCodes, $aSelectedModules, $sSourceDir, $sExtensionDir, $bUseSymbolicLinks ); return $this->ComputeNextStep($sStep); case 'setup-audit': $this->oRunTimeEnvironment->DataToCleanupAudit(); return $this->ComputeNextStep($sStep); case 'complete': return $this->GetNextStep('', 'Completed', 100); default: return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', '', self::ERROR); } } catch (Exception $e) { SetupLog::Exception("$sStep failed", $e); $aResult = $this->GetNextStep('', '', 100, $e->getMessage(), '', self::ERROR); $aResult['error_code'] = $e->getCode(); return $aResult; } finally { $fDuration = round(microtime(true) - $fStart, 2); SetupLog::Info("##### STEP {$sStep} duration: {$fDuration}s"); } } protected function IsDataAuditRequired(): bool { if (!$this->HasOptionalStep('setup-audit', false)) { return false; } if ('install' === $this->oParams->Get('mode')) { return false; } $aInstalledInfo = $this->oRunTimeEnvironment->GetApplicationVersion($this->GetConfig()); $sInstalledVersion = $aInstalledInfo['product_version']; if ($sInstalledVersion !== ITOP_VERSION_FULL) { return false; } $sFinalEnvDir = APPROOT.'env-'.$this->oRunTimeEnvironment->GetFinalEnv(); return is_dir($sFinalEnvDir); } public function GetStepNames(): array { $aStepNames = ['']; if ($this->HasOptionalStep('copy')) { $aStepNames[] = 'copy'; } $aStepNames[] = 'compile'; if ($this->IsDataAuditRequired()) { $aStepNames[] = 'setup-audit'; } $aStepNames[] = 'complete'; return $aStepNames; } }