From 06b0cad74fe7bf6fc563013573e64e3f07e815d0 Mon Sep 17 00:00:00 2001 From: Timothee Date: Tue, 3 Feb 2026 11:50:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B09010=20Fix=20flags=20for=20missing?= =?UTF-8?q?=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/wizardsteps.class.inc.php | 6 +- .../setup/WizStepModulesChoiceTest.php | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index f8c947f85f..2ee18d9e62 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -1939,12 +1939,12 @@ public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSe $oITopExtension = $this->oExtensionsMap->GetFromExtensionCode($aChoice['extension_code']); $bCanBeUninstalled = isset($aChoice['uninstallable']) ? $aChoice['uninstallable'] === true || $aChoice['uninstallable'] === 'yes' : $oITopExtension->CanBeUninstalled(); $bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId); - $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || $bUpgradeMode && $oITopExtension->bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck; - $bMissingFromDisk = isset($aChoice['missing']) && $aChoice['missing'] === true; + + $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || $bUpgradeMode && !$bMissingFromDisk && $oITopExtension->bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck; $bInstalled = $bMissingFromDisk || $oITopExtension->bInstalled; $bDisabled = $bMandatory || $bAllDisabled || $bMissingFromDisk; - $bChecked = $bMandatory || $bSelected; + $bChecked = !$bMissingFromDisk && ($bMandatory || $bSelected); if (isset($aChoice['sub_options'])) { $aOptions = $aChoice['sub_options']['options'] ?? []; diff --git a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php index 742cf00bc8..152284a1ca 100644 --- a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php @@ -67,6 +67,69 @@ public function ProviderComputeChoiceFlags() 'checked' => true, ], ], + 'A missing extension should be disabled and unchecked' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => false, + 'missing' => true, + 'uninstallable' => true, + ], + 'bCurrentSelected' => false, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => true, + 'installed' => true, + 'disabled' => true, + 'checked' => false, + ], + ], + 'A missing extension should always be disabled and unchecked, even when mandatory' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => true, + 'missing' => true, + 'uninstallable' => true, + ], + 'bCurrentSelected' => false, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => true, + 'installed' => true, + 'disabled' => true, + 'checked' => false, + ], + ], + 'A missing extension should always be disabled and unchecked, even when non-uninstallable' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => true, + 'missing' => true, + 'uninstallable' => false, + ], + 'bCurrentSelected' => false, + 'aExpectedFlags' => [ + 'uninstallable' => false, + 'missing' => true, + 'installed' => true, + 'disabled' => true, + 'checked' => false, + ], + ], 'An installed but not selected extension should not be checked and be enabled' => [ 'aExtensionsOnDiskOrDb' => [ 'itop-ext1' => [ From c3cc07316e9a384c9aee91fb9d92583b04ba342e Mon Sep 17 00:00:00 2001 From: Timothee Date: Tue, 3 Feb 2026 11:54:30 +0100 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B09010=20Add=20explanation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/wizardsteps.class.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index 2ee18d9e62..56fd97db03 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -1937,6 +1937,7 @@ protected function GetStepInfo($idx = null) public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSelectedComponents, bool $bAllDisabled, bool $bDisableUninstallCheck, bool $bUpgradeMode) { $oITopExtension = $this->oExtensionsMap->GetFromExtensionCode($aChoice['extension_code']); + //If the extension is missing from disk, it won't exist in the ExtensionsMap, thus returning null $bCanBeUninstalled = isset($aChoice['uninstallable']) ? $aChoice['uninstallable'] === true || $aChoice['uninstallable'] === 'yes' : $oITopExtension->CanBeUninstalled(); $bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId); $bMissingFromDisk = isset($aChoice['missing']) && $aChoice['missing'] === true;