Skip to content

Commit 64f5e0c

Browse files
authored
N°9141 Log when extension uninstallation is forced
1 parent f666486 commit 64f5e0c

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

setup/wizardsteps/WizStepInstall.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,34 @@ public function Display(WebPage $oPage)
8383
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
8484
if (!$this->CheckDependencies()) {
8585
$oPage->error($this->sDependencyIssue);
86+
$oPage->add_ready_script(<<<JS
87+
$("#wiz_form").data("installation_status", "error");
88+
document.getElementById("setup_msg").innerText = "Unmet dependencies";
89+
JS);
90+
return;
91+
}
92+
93+
//When the setup reach this step, it already checked whether extensions were uninstallable (during WizStepModulesChoice). We only need to log what has been done.
94+
if ($this->oWizard->GetParameter('force-uninstall', false)) {
95+
SetupLog::Warning("User disabled uninstallation checks");
96+
}
97+
$aExtensionsRemoved = json_decode($this->oWizard->GetParameter('removed_extensions'), true) ?? [];
98+
$aExtensionsNotUninstallable = json_decode($this->oWizard->GetParameter('extensions_not_uninstallable'));
99+
$aExtensionsForceUninstalled = [];
100+
foreach ($aExtensionsRemoved as $sExtensionCode => $sLabel) {
101+
if (in_array($sExtensionCode, $aExtensionsNotUninstallable)) {
102+
$aExtensionsForceUninstalled[] = $sExtensionCode;
103+
}
104+
}
105+
if (count($aExtensionsForceUninstalled)) {
106+
SetupLog::Warning("Extensions uninstalled forcefully : ".implode(',', $aExtensionsForceUninstalled));
86107
}
87108

88-
$oPage->add_ready_script(
89-
<<<JS
109+
$oPage->add_ready_script(<<<JS
90110
$("#wiz_form").data("installation_status", "not started");
91111
ExecuteStep("");
92-
JS
93-
);
112+
JS);
113+
94114
}
95115

96116
/**

setup/wizardsteps/WizStepModulesChoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function GetAddedAndRemovedExtensions($aSelectedExtensions)
107107
$bSelected = in_array($oExtension->sCode, $aSelectedExtensions);
108108
if ($oExtension->bInstalled && !$bSelected) {
109109
$aExtensionsRemoved[$oExtension->sCode] = $oExtension->sLabel;
110-
if (!$oExtension->CanBeUninstalled()) {
110+
if (!$oExtension->CanBeUninstalled() || $oExtension->sSource === iTopExtension::SOURCE_REMOTE) {
111111
$aExtensionsNotUninstallable[$oExtension->sCode] = true;
112112
}
113113
} elseif (!$oExtension->bInstalled && $bSelected) {

0 commit comments

Comments
 (0)