diff --git a/setup/wizardsteps/WizStepModulesChoice.php b/setup/wizardsteps/WizStepModulesChoice.php index 567c5f6ea8..9afb266cb7 100644 --- a/setup/wizardsteps/WizStepModulesChoice.php +++ b/setup/wizardsteps/WizStepModulesChoice.php @@ -758,12 +758,11 @@ public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSe if ($bMissingFromDisk) { $bDisabled = true; $bChecked = false; - } elseif ($bDependencyIssue) { - $bDisabled = true; - $bChecked = false; } elseif ($bMandatory) { $bDisabled = true; $bChecked = true; + } elseif ($bDependencyIssue) { + $bDisabled = !$bDisableUninstallCheck; } elseif ($bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck) { $bChecked = true; $bDisabled = true; @@ -813,6 +812,9 @@ public function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $aDefau if ($aFlags['disabled'] && !$aFlags['checked'] && !$bDisableUninstallCheck && (!$aFlags['uninstallable'] || $aFlags['mandatory'])) { $this->bCanMoveForward = false;//Disable "Next" + } elseif (!$bDisableUninstallCheck && $aFlags['dependency_issue']) { + //If there is a dependency issue, the user cannot move forward without forced uninstall + $this->bCanMoveForward = false; } $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId, $sChoiceId, $aFlags); diff --git a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php index 66dd565c54..c3a2084da2 100644 --- a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php @@ -394,7 +394,7 @@ public function ProviderComputeChoiceFlags() 'mandatory' => false, ], ], - 'A non installed extension with missing dependencies should be not checked and disabled' => [ + 'A non installed and non mandatory extension with missing dependencies and without force uninstall should be not checked and disabled' => [ 'aExtensionsOnDiskOrDb' => [ 'itop-ext1' => [ 'installed' => false, @@ -421,7 +421,7 @@ public function ProviderComputeChoiceFlags() 'mandatory' => false, ], ], - 'An installed extension with missing dependencies should be not checked and disabled' => [ + 'An installed non mandatory extension with missing dependencies and without force uninstall should be not checked and disabled' => [ 'aExtensionsOnDiskOrDb' => [ 'itop-ext1' => [ 'installed' => true, @@ -448,6 +448,114 @@ public function ProviderComputeChoiceFlags() 'mandatory' => false, ], ], + 'A non installed and non mandatory extension with missing dependencies and force uninstall should be not checked and enabled' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => false, + 'missing_dependencies' => [ + 'itop-ext1-1', + ], + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => false, + 'uninstallable' => true, + 'missing_dependencies' => true, + ], + 'bCurrentSelected' => false, + 'bDisableUninstallChecks' => true, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => false, + 'installed' => false, + 'disabled' => false, + 'checked' => false, + 'dependency_issue' => true, + 'mandatory' => false, + ], + ], + 'An installed non mandatory extension with missing dependencies and force uninstall should be not checked and enabled' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + 'missing_dependencies' => [ + 'itop-ext1-1', + ], + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => false, + 'uninstallable' => true, + 'missing_dependencies' => true, + ], + 'bCurrentSelected' => false, + 'bDisableUninstallChecks' => true, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => false, + 'installed' => true, + 'disabled' => false, + 'checked' => false, + 'dependency_issue' => true, + 'mandatory' => false, + ], + ], + 'An installed mandatory extension with missing dependencies and without force uninstall should be checked and disabled' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + 'missing_dependencies' => [ + 'itop-ext1-1', + ], + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => true, + 'uninstallable' => true, + 'missing_dependencies' => true, + ], + 'bCurrentSelected' => false, + 'bDisableUninstallChecks' => true, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => false, + 'installed' => true, + 'disabled' => true, + 'checked' => true, + 'dependency_issue' => true, + 'mandatory' => true, + ], + ], + 'An non installed mandatory extension with missing dependencies and without force uninstall should be checked and disabled' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => false, + 'missing_dependencies' => [ + 'itop-ext1-1', + ], + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'mandatory' => true, + 'uninstallable' => true, + 'missing_dependencies' => true, + ], + 'bCurrentSelected' => false, + 'bDisableUninstallChecks' => true, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => false, + 'installed' => false, + 'disabled' => true, + 'checked' => true, + 'dependency_issue' => true, + 'mandatory' => true, + ], + ], ]; }