From 1479b4d5ff32d1fb17fc5f9bc07ad8adca618e18 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 29 May 2026 17:22:59 +0200 Subject: [PATCH 1/4] Setup fast track # Conflicts: # setup/wizardsteps/WizStepLandingBeforeAudit.php # setup/wizardsteps/WizStepWelcome.php --- setup/ajax.dataloader.php | 1 + setup/wizard.php | 1 + setup/wizardcontroller.class.inc.php | 6 +- .../wizardsteps/WizStepLandingBeforeAudit.php | 11 ++ setup/wizardsteps/WizStepWelcome.php | 118 +++++++++++++----- setup/wizardsteps/WizardStep.php | 4 + 6 files changed, 107 insertions(+), 34 deletions(-) diff --git a/setup/ajax.dataloader.php b/setup/ajax.dataloader.php index f2e9be4669..7c88f301cd 100644 --- a/setup/ajax.dataloader.php +++ b/setup/ajax.dataloader.php @@ -124,6 +124,7 @@ function FatalErrorCatcher($sOutput) // Never cache this page header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past +$oCtx = new ContextTag(ContextTag::TAG_SETUP); /** * Main program diff --git a/setup/wizard.php b/setup/wizard.php index f7367dd1d0..b1f6e4c0dd 100644 --- a/setup/wizard.php +++ b/setup/wizard.php @@ -61,6 +61,7 @@ function json_decode($json, $assoc = null) //N°3671 setup context: force $bForceTrustProxy to be persisted in next calls utils::GetAbsoluteUrlAppRoot(true); $oWizard = new WizardController('WizStepWelcome'); +$oCtx = new ContextTag(ContextTag::TAG_SETUP); //N°3952 if (SetupUtils::IsSessionSetupTokenValid()) { // Normal operation diff --git a/setup/wizardcontroller.class.inc.php b/setup/wizardcontroller.class.inc.php index 860f7f666b..3015b35a69 100644 --- a/setup/wizardcontroller.class.inc.php +++ b/setup/wizardcontroller.class.inc.php @@ -196,6 +196,8 @@ protected function DisplayStep(WizardStep $oStep): void SetupLog::Info("=== Setup screen: ".$oStep->GetTitle().' ('.get_class($oStep).')'); $oPage = new SetupPage($oStep->GetTitle()); $oPage->LinkScriptFromAppRoot('setup/setup.js'); + $oStep->PreFormDisplay($oPage); + $oPage->add('
'); $oPage->add('
'); $oStep->Display($oPage); @@ -263,8 +265,8 @@ protected function DisplayStep(WizardStep $oStep): void $oPage->output(); } /** - * Make the wizard run: Start, Next or Back depending WizardUpdateButtons(); -on the page's parameters + * Make the wizard run: 'Start', 'Next' or 'Back' depending WizardUpdateButtons(); + * on the page's parameters */ public function Run() { diff --git a/setup/wizardsteps/WizStepLandingBeforeAudit.php b/setup/wizardsteps/WizStepLandingBeforeAudit.php index 8e92fa74d5..691f851212 100644 --- a/setup/wizardsteps/WizStepLandingBeforeAudit.php +++ b/setup/wizardsteps/WizStepLandingBeforeAudit.php @@ -52,6 +52,17 @@ public function Display(SetupPage $oPage): void */ public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState { + if ($this->oWizard->GetParameter('skip_wizard', false)) { + $oRuntimeEnv = new RunTimeEnvironment(); + $sBuildConfigFile = APPCONF.$oRuntimeEnv->GetBuildEnv().'/'.ITOP_CONFIG_FILE; + $oConfig = new Config($sBuildConfigFile); + $oExtensionMap = iTopExtensionsMap::GetExtensionsMap($oRuntimeEnv->GetBuildEnv()); + $aExtensionsFromDatabase = $oExtensionMap->GetChoicesFromDatabase($oConfig); + $this->oWizard->SetParameter('selected_extensions', json_encode($aExtensionsFromDatabase)); + $adModulesFromDatabase = ModuleInstallationRepository::GetInstance()->ReadComputeInstalledModules($oConfig); + $this->oWizard->SetParameter('selected_modules', json_encode(array_keys($adModulesFromDatabase))); + } + $aWizardSteps = $this->GetWizardSteps(); $this->oWizard->SetWizardSteps($aWizardSteps); $this->sCurrentState = count($aWizardSteps) - 1; diff --git a/setup/wizardsteps/WizStepWelcome.php b/setup/wizardsteps/WizStepWelcome.php index 9420f0ea8c..ebbf7ab7ee 100644 --- a/setup/wizardsteps/WizStepWelcome.php +++ b/setup/wizardsteps/WizStepWelcome.php @@ -24,6 +24,15 @@ class WizStepWelcome extends WizardStep { protected $bCanMoveForward; + private array $aInfo; + private array $aWarnings; + private array $aErrors; + + public function __construct(WizardController $oWizard, $sCurrentState) + { + parent::__construct($oWizard, $sCurrentState); + $this->CheckInstallation(); + } public function GetTitle() { @@ -66,39 +75,14 @@ public function Display(SetupPage $oPage): void EOF ); $oPage->add('

'.ITOP_APPLICATION.' Installation Wizard

'); - $aResults = SetupUtils::CheckPhpAndExtensions(); - $this->bCanMoveForward = true; - $aInfo = []; - $aWarnings = []; - $aErrors = []; - foreach ($aResults as $oCheckResult) { - switch ($oCheckResult->iSeverity) { - case CheckResult::ERROR: - $aErrors[] = $oCheckResult->sLabel; - $this->bCanMoveForward = false; - break; - - case CheckResult::WARNING: - $aWarnings[] = $oCheckResult->sLabel; - break; - - case CheckResult::INFO: - $aInfo[] = $oCheckResult->sLabel; - break; - - case CheckResult::TRACE: - SetupLog::Ok($oCheckResult->sLabel); - break; - } - } $sStyle = 'style="display:none;overflow:auto;"'; $sToggleButtons = ''; - if (count($aErrors) > 0) { + if (count($this->aErrors) > 0) { $sStyle = 'style="overflow:auto;"'; - $sTitle = count($aErrors).' Error(s), '.count($aWarnings).' Warning(s).'; + $sTitle = count($this->aErrors).' Error(s), '.count($this->aWarnings).' Warning(s).'; $sH2Class = 'text-error'; - } elseif (count($aWarnings) > 0) { - $sTitle = count($aWarnings).' Warning(s) '.$sToggleButtons; + } elseif (count($this->aWarnings) > 0) { + $sTitle = count($this->aWarnings).' Warning(s) '.$sToggleButtons; $sH2Class = 'text-warning'; } else { $sTitle = 'Ok. '.$sToggleButtons; @@ -110,13 +94,13 @@ public function Display(SetupPage $oPage): void
HTML ); - foreach ($aErrors as $sText) { + foreach ($this->aErrors as $sText) { $oPage->error($sText); } - foreach ($aWarnings as $sText) { + foreach ($this->aWarnings as $sText) { $oPage->warning($sText); } - foreach ($aInfo as $sText) { + foreach ($this->aInfo as $sText) { $oPage->ok($sText); } $oPage->add('
'); @@ -127,8 +111,78 @@ public function Display(SetupPage $oPage): void $oPage->add_ready_script('CheckDirectoryConfFilesPermissions("'.utils::GetItopVersionWikiSyntax().'")'); } + /** + * Add post display stuff to the setup screen + * @param \SetupPage $oPage + * + * @return void + */ + public function PreFormDisplay(SetupPage $oPage) + { + if ($this->bCanMoveForward) { + $sBuildConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE; + if (file_exists($sBuildConfigFile)) { + $oContextTag = new ContextTag(ContextTag::TAG_SETUP); + $sToken = SetupUtils::CreateSetupToken(); + $oPage->add( + << + Fast track + + + + + + + + + + +
+ + +
+ Normal track +
+HTML + ); + } + } + } + public function CanMoveForward() { return $this->bCanMoveForward; } + + /** + */ + public function CheckInstallation(): void + { + $aResults = SetupUtils::CheckPhpAndExtensions(); + $this->bCanMoveForward = true; + $this->aInfo = []; + $this->aWarnings = []; + $this->aErrors = []; + foreach ($aResults as $oCheckResult) { + switch ($oCheckResult->iSeverity) { + case CheckResult::ERROR: + $this->aErrors[] = $oCheckResult->sLabel; + $this->bCanMoveForward = false; + break; + + case CheckResult::WARNING: + $this->aWarnings[] = $oCheckResult->sLabel; + break; + + case CheckResult::INFO: + $this->aInfo[] = $oCheckResult->sLabel; + break; + + case CheckResult::TRACE: + SetupLog::Ok($oCheckResult->sLabel); + break; + } + } + } } diff --git a/setup/wizardsteps/WizardStep.php b/setup/wizardsteps/WizardStep.php index a953c52756..cc9f2190d8 100644 --- a/setup/wizardsteps/WizardStep.php +++ b/setup/wizardsteps/WizardStep.php @@ -76,6 +76,10 @@ public function PostFormDisplay(SetupPage $oPage) { } + public function PreFormDisplay(SetupPage $oPage) + { + } + protected function CheckDependencies() { if (is_null($this->bDependencyCheck)) { From 6e918ce12c452ca4460258f54f5925a7ac1b5696 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 29 May 2026 17:40:05 +0200 Subject: [PATCH 2/4] Setup fast track (fix setup token) --- setup/wizardsteps/WizStepWelcome.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup/wizardsteps/WizStepWelcome.php b/setup/wizardsteps/WizStepWelcome.php index ebbf7ab7ee..c5ff24fe00 100644 --- a/setup/wizardsteps/WizStepWelcome.php +++ b/setup/wizardsteps/WizStepWelcome.php @@ -122,8 +122,6 @@ public function PreFormDisplay(SetupPage $oPage) if ($this->bCanMoveForward) { $sBuildConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE; if (file_exists($sBuildConfigFile)) { - $oContextTag = new ContextTag(ContextTag::TAG_SETUP); - $sToken = SetupUtils::CreateSetupToken(); $oPage->add( << @@ -132,8 +130,8 @@ public function PreFormDisplay(SetupPage $oPage) - - + + From 81386abe5aa653484a8cc2a3cbb77924306c96e3 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 29 May 2026 17:56:28 +0200 Subject: [PATCH 3/4] Setup fast track (keep current options) --- setup/wizardsteps/WizStepWelcome.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/setup/wizardsteps/WizStepWelcome.php b/setup/wizardsteps/WizStepWelcome.php index c5ff24fe00..0816d61eb7 100644 --- a/setup/wizardsteps/WizStepWelcome.php +++ b/setup/wizardsteps/WizStepWelcome.php @@ -117,15 +117,13 @@ public function Display(SetupPage $oPage): void * * @return void */ - public function PreFormDisplay(SetupPage $oPage) + public function PostFormDisplay(SetupPage $oPage) { if ($this->bCanMoveForward) { $sBuildConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE; if (file_exists($sBuildConfigFile)) { $oPage->add( << - Fast track
@@ -134,14 +132,10 @@ public function PreFormDisplay(SetupPage $oPage)
- +
- -
- Normal track -
HTML ); } From 94e4425106c5e1173ae59a36e71ff3e773100a2d Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 19 Jun 2026 13:40:32 +0200 Subject: [PATCH 4/4] Remove Fast Setup button from "Application Update" screen --- .../src/Controller/AjaxController.php | 25 ---------- .../templates/SelectUpdateFile.html.twig | 7 --- .../templates/SelectUpdateFile.ready.js.twig | 47 ------------------- setup/wizardsteps/WizStepWelcome.php | 2 - 4 files changed, 81 deletions(-) diff --git a/datamodels/2.x/itop-core-update/src/Controller/AjaxController.php b/datamodels/2.x/itop-core-update/src/Controller/AjaxController.php index 777858e368..7a100ed28a 100644 --- a/datamodels/2.x/itop-core-update/src/Controller/AjaxController.php +++ b/datamodels/2.x/itop-core-update/src/Controller/AjaxController.php @@ -14,13 +14,11 @@ use Combodo\iTop\DBTools\Service\DBToolsUtils; use Combodo\iTop\FilesInformation\Service\FileNotExistException; use Combodo\iTop\FilesInformation\Service\FilesInformation; -use Config; use ContextTag; use Dict; use Exception; use IssueLog; use MetaModel; -use RunTimeEnvironment; use SecurityException; use SetupUtils; use utils; @@ -232,29 +230,6 @@ public function OperationUpdateDatabase() $this->DisplayJSONPage($aParams, $iResponseCode); } - public function OperationRebuildToolkitEnvironment() - { - $sTransactionId = utils::GetNewTransactionId(); - $aParams = []; - $aParams['sTransactionId'] = $sTransactionId; - $aParams['bStatus'] = true; - - $iResponseCode = 200; - try { - $aParams['sAjaxURL'] = utils::GetAbsoluteUrlAppRoot().'/pages/UI.php'; - $oConfig = new Config(APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE); - $oEnvironment = new RunTimeEnvironment(ITOP_DEFAULT_ENV); - $oEnvironment->WriteConfigFileSafe($oConfig); - $oEnvironment->CompileFrom(ITOP_DEFAULT_ENV); - } catch (Exception $e) { - IssueLog::Error('RebuildToolkitEnvironment: '.$e->getMessage()); - $aParams['sError'] = $e->getMessage(); - $iResponseCode = 500; - $aParams['bStatus'] = false; - } - $this->DisplayJSONPage($aParams, $iResponseCode); - } - /** * @throws \SecurityException if CSRF token invalid * diff --git a/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.html.twig b/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.html.twig index 389641e683..f7aa9a9d14 100644 --- a/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.html.twig +++ b/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.html.twig @@ -90,13 +90,6 @@ {% UIForm Standard {'sId':'launch-setup-form', Action:sLaunchSetupUrl} %} {% UIButton ForDestructiveAction {'sLabel':'iTopUpdate:UI:SetupLaunch'|dict_s, 'sName':'launch-setup', 'sValue':'launch-setup', 'bIsSubmit':true, 'sId':'launch-setup'} %} {% EndUIForm %} - {% UIAlert ForInformation {sId:'fast-setup-alert', AddCSSClass:'ibo-is-hidden'} %} - {% UIContentBlock Standard {sId:'fast-setup-content', aContainerClasses:['ibo-fast-setup-content']} %} - {{ 'iTopUpdate:UI:SetupMessage:Compile'|dict_s }} - {% EndUIContentBlock %} - {% EndUIAlert %} - {% UIButton ForDestructiveAction {sLabel:'iTopUpdate:UI:FastSetupLaunch'|dict_s, sName:'launch-fast-setup', sValue:'launch-fast-setup', sId:'launch-fast-setup'} %} - {% UISpinner Standard {sId:'fast-setup-wait', IsHidden:true} %} {% EndUIFieldSet %} {% endif %} diff --git a/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.ready.js.twig b/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.ready.js.twig index b1e3111fb4..e9d1e3df17 100644 --- a/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.ready.js.twig +++ b/datamodels/2.x/itop-core-update/templates/SelectUpdateFile.ready.js.twig @@ -116,51 +116,4 @@ $("#launch-setup-form").on("submit", function () { return window.confirm("{{ 'iTopUpdate:UI:SetupLaunchConfirm'|dict_s }}"); }); -$("#launch-fast-setup").on("click", function(e) { - var oMessage = $("#fast-setup-alert"); - var oContent = $("#fast-setup-content"); - oMessage.removeClass("ibo-is-hidden"); - oMessage.removeClass("ibo-is-failure"); - oMessage.removeClass("ibo-is-success"); - oMessage.addClass("ibo-is-information"); - oContent.html("{{ 'iTopUpdate:UI:SetupMessage:Compile'|dict_s }}"); - - let fast_setup_wait = $("#fast-setup-wait"); - fast_setup_wait.removeClass("ibo-is-hidden"); - $(this).prop("disabled", true); - - $.ajax({ - method: "POST", - url: "{{ sAjaxURL|raw }}", - data: { - route: "core_update_ajax.rebuild_toolkit_environment" - }, - dataType: "json", - complete: function(jqXHR, textStatus) { - $("#fast-setup-wait").addClass("ibo-is-hidden"); - $("#launch-fast-setup").prop("disabled", false); - fast_setup_wait.addClass("ibo-is-hidden"); - }, - success: function (data) { - oMessage.removeClass("ibo-is-information"); - - if (data.bStatus) { - oMessage.removeClass("ibo-is-failure"); - oMessage.addClass("ibo-is-success"); - oContent.html("{{ 'iTopUpdate:UI:SetupMessage:UpdateDone'|dict_s }}"); - } else { - oMessage.removeClass("ibo-is-success"); - oMessage.addClass("ibo-is-failure"); - oContent.html(data.sError); - } - }, - error: function(jqXHR, textStatus, errorThrown) { - oMessage.removeClass("ibo-is-information"); - oMessage.removeClass("ibo-is-success"); - oMessage.addClass("ibo-is-failure"); - oContent.html(textStatus + ' ' + errorThrown); - } - }); - -}); diff --git a/setup/wizardsteps/WizStepWelcome.php b/setup/wizardsteps/WizStepWelcome.php index 0816d61eb7..c9b878eb80 100644 --- a/setup/wizardsteps/WizStepWelcome.php +++ b/setup/wizardsteps/WizStepWelcome.php @@ -128,8 +128,6 @@ public function PostFormDisplay(SetupPage $oPage) - -