Compare commits

...

1 Commits

Author SHA1 Message Date
lenaick.moreira
1dd44e53c4 N°9861 - Keep current choice button is too permissive 2026-08-04 10:32:07 +02:00
2 changed files with 33 additions and 11 deletions

View File

@@ -80,6 +80,22 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
$aSelectedComponents = json_decode($this->oWizard->GetParameter('selected_components'), true);
}
$bDisableUninstallCheck = (bool)$this->oWizard->GetParameter('force-uninstall', false);
$bRemoteExtensionsShouldBeMandatory = !$bDisableUninstallCheck;
$aOptions = $this->oExtensionsMap->GetAllExtensionsOptionInfo($bRemoteExtensionsShouldBeMandatory);
foreach ($aOptions as $index => $aChoice) {
$sChoiceId = self::$SEP.$index;
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, false, $bDisableUninstallCheck, true);
if (!$this->CanMoveForwardFromChoiceFlags($aFlags, $bDisableUninstallCheck)) {
// If the user has selected incompatible modules, we need to go back to the extensions choice step which is the last modules choice step in the wizard
$iCountModulesChoiceSteps = count(array_filter($aWizardSteps, fn (array $step): bool => $step['class'] === WizStepModulesChoice::class));
array_pop($aWizardSteps);
$this->oWizard->SetWizardSteps($aWizardSteps);
$this->oWizard->SetParameter('_steps', $aWizardSteps);
return new WizardState(WizStepModulesChoice::class, $iCountModulesChoiceSteps - 1);
}
}
// Save the choices for the summary step
$sDisplayChoices = '<ul>';
$i = 0;
@@ -104,7 +120,7 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
public function GetPossibleSteps()
{
return [WizStepDataAudit::class];
return [WizStepDataAudit::class, WizStepModulesChoice::class];
}
public function GetNextButtonLabel()

View File

@@ -702,8 +702,8 @@ EOF
protected function GetStepInfo($idx = null)
{
$index = $idx ?? $this->GetStepIndex();
$bRemoteExtensionsShouldBeMandatory = !$this->oWizard->GetParameter('force-uninstall', false);
if (is_null($this->aSteps)) {
$bRemoteExtensionsShouldBeMandatory = !$this->oWizard->GetParameter('force-uninstall', false);
$this->oWizard->SetParameter('additional_extensions_modules', json_encode([])); // Default value, no additional extensions
if (@file_exists($this->GetSourceFilePath())) {
@@ -817,15 +817,7 @@ EOF
foreach ($aOptions as $index => $aChoice) {
$sChoiceId = $sParentId.self::$SEP.$index;
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck, $this->bUpgrade);
if (!$aFlags['checked'] && $aFlags['installed'] && !$bDisableUninstallCheck && (!$aFlags['uninstallable'] || $aFlags['mandatory'])) {
// If the user cannot uninstall a mandatory extension, he cannot move forward unless he uses the "force-uninstall" option
// The same applies if the extension is not uninstallable (i.e. a product extension)
$this->bCanMoveForward = false;
} elseif ($aFlags['checked'] && $aFlags['disabled'] && $aFlags['dependency_issue'] && !$bDisableUninstallCheck) {
// If there is a dependency issue on a selected and disabled extension, the user cannot move forward unless he uses the "force-uninstall" option
$this->bCanMoveForward = false;
}
$this->bCanMoveForward = $this->bCanMoveForward && $this->CanMoveForwardFromChoiceFlags($aFlags, $bDisableUninstallCheck);
$this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId, $sChoiceId, $aFlags);
}
@@ -872,6 +864,20 @@ EOF
}
}
protected function CanMoveForwardFromChoiceFlags(array $aFlags, bool $bDisableUninstallCheck): bool
{
if (!$aFlags['checked'] && $aFlags['installed'] && !$bDisableUninstallCheck && (!$aFlags['uninstallable'] || $aFlags['mandatory'])) {
// If the user cannot uninstall a mandatory extension, he cannot move forward unless he uses the "force-uninstall" option
// The same applies if the extension is not uninstallable (i.e. a product extension)
return false;
} elseif ($aFlags['checked'] && $aFlags['disabled'] && $aFlags['dependency_issue'] && !$bDisableUninstallCheck) {
// If there is a dependency issue on a selected and disabled extension, the user cannot move forward unless he uses the "force-uninstall" option
return false;
}
return true;
}
protected function DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceName, $sChoiceId, $aFlags, $sInputType = 'checkbox')
{
$sMoreInfo = (isset($aChoice['more_info']) && ($aChoice['more_info'] != '')) ? '