Compare commits

...

2 Commits

Author SHA1 Message Date
lenaick.moreira
cfcad3b39a N°9861 - Changes from review 2026-08-05 18:12:58 +02:00
lenaick.moreira
1dd44e53c4 N°9861 - Keep current choice button is too permissive 2026-08-04 10:32:07 +02:00
3 changed files with 47 additions and 12 deletions

View File

@@ -59,7 +59,7 @@ class WizardController
* Removes information about the previous step from the stack
* @return array{'class': string, 'state': string}
*/
protected function PopStep(): array
public function PopStep(): array
{
$aStep = array_pop($this->aWizardSteps);
$this->SetParameter('_steps', $this->aWizardSteps);
@@ -335,4 +335,21 @@ EOF
{
$this->oSessionParameters->Erase();
}
/**
* @param string $sStepClass The class name of the step to find the latest state for
*
* @return WizardState
*/
public function GetLatestWizardStateFromStepClass(string $sStepClass, bool $bPopStep = true): WizardState
{
$iCountModulesChoiceSteps = count(array_filter($this->aWizardSteps, fn (array $step): bool => $step['class'] === $sStepClass && $step['state'] !== ''));
$sStepState = $iCountModulesChoiceSteps > 0 ? (string) ($iCountModulesChoiceSteps - 1) : '';
if ($bPopStep) {
$this->PopStep();
}
return new WizardState($sStepClass, $sStepState);
}
}

View File

@@ -69,6 +69,7 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
$aWizardSteps = $this->GetWizardSteps();
if ($bSkipWizard) {
$this->oWizard->SetParameter('_steps', $aWizardSteps);
$this->oWizard->SetWizardSteps($aWizardSteps);
}
// Component selection in previous screens
@@ -80,6 +81,17 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
$aSelectedComponents = json_decode($this->oWizard->GetParameter('selected_components'), true);
}
$bForceUninstall = (bool)$this->oWizard->GetParameter('force-uninstall', false);
$aOptions = $this->oExtensionsMap->GetAllExtensionsOptionInfo(bRemoteExtensionsShouldBeMandatory: !$bForceUninstall);
foreach ($aOptions as $index => $aChoice) {
$sChoiceId = self::$SEP.$index;
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, false, $bForceUninstall, true);
if (!$this->CanMoveForwardFromChoiceFlags($aFlags, $bForceUninstall)) {
// 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
return $this->oWizard->GetLatestWizardStateFromStepClass(WizStepModulesChoice::class);
}
}
// Save the choices for the summary step
$sDisplayChoices = '<ul>';
$i = 0;
@@ -104,7 +116,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'] != '')) ? '