-
Notifications
You must be signed in to change notification settings - Fork 279
N°9010 fix flags when extension missing #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/uninstallation
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1937,14 +1937,15 @@ 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); | ||
| $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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. variable $bMandatory has become sth much more complex than his name. maybe keep its logic simple (mandatory is mandatory). and the addional stuff can come after to treat each flag. |
||
| $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'] ?? []; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
| ], | ||
| ], | ||
|
Comment on lines
+70
to
+132
|
||
| 'An installed but not selected extension should not be checked and be enabled' => [ | ||
| 'aExtensionsOnDiskOrDb' => [ | ||
| 'itop-ext1' => [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whole method has become uggly and hard to understand functionally... even if most cases are covered by tests (which is nice).
please refactor it to have sth we can understand. for ex. use [if else] structure to spit things apart. on one side treat the exceptional case (extension missing on disk). then others...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor should not be so long as you have the cover :)