mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°7407 - fix missing extension installation via unattended from production-modules or extension folder
This commit is contained in:
@@ -17,6 +17,9 @@ class InstallationFileService {
|
||||
/** @var \RunTimeEnvironment $oProductionEnv */
|
||||
private $oProductionEnv;
|
||||
|
||||
/** @var \ItopExtensionsMap $oProductionEnv */
|
||||
private $oItopExtensionsMap;
|
||||
|
||||
private $sTargetEnvironment;
|
||||
private $sInstallationPath;
|
||||
private $aSelectedModules;
|
||||
@@ -30,7 +33,8 @@ class InstallationFileService {
|
||||
* @param string $sInstallationPath
|
||||
* @param string $sTargetEnvironment
|
||||
* @param array $aSelectedExtensions
|
||||
* @param bool $bInstallationOptionalChoicesChecked : this option is used only when no extensions are selected (ie empty $aSelectedExtensions)
|
||||
* @param bool $bInstallationOptionalChoicesChecked : this option is used only when no extensions are selected (ie empty
|
||||
* $aSelectedExtensions)
|
||||
*/
|
||||
public function __construct(string $sInstallationPath, string $sTargetEnvironment='production', array $aSelectedExtensions = [], bool $bInstallationOptionalChoicesChecked=true) {
|
||||
$this->sInstallationPath = $sInstallationPath;
|
||||
@@ -42,6 +46,15 @@ class InstallationFileService {
|
||||
$this->bInstallationOptionalChoicesChecked = $bInstallationOptionalChoicesChecked;
|
||||
}
|
||||
|
||||
public function Init(): void {
|
||||
clearstatcache();
|
||||
|
||||
$this->ProcessDefaultModules();
|
||||
$this->ProcessInstallationChoices();
|
||||
$this->ProcessExtensionModulesNotSpecifiedInChoices();
|
||||
$this->ProcessAutoSelectModules();
|
||||
}
|
||||
|
||||
public function GetProductionEnv(): RunTimeEnvironment {
|
||||
if (is_null($this->oProductionEnv)){
|
||||
$this->oProductionEnv = new RunTimeEnvironment();
|
||||
@@ -57,6 +70,17 @@ class InstallationFileService {
|
||||
return $this->aAfterComputationSelectedExtensions;
|
||||
}
|
||||
|
||||
public function SetItopExtensionsMap(ItopExtensionsMap $oItopExtensionsMap): void {
|
||||
$this->oItopExtensionsMap = $oItopExtensionsMap;
|
||||
}
|
||||
|
||||
public function GetItopExtensionsMap(): ItopExtensionsMap {
|
||||
if (is_null($this->oItopExtensionsMap)){
|
||||
$this->oItopExtensionsMap = new iTopExtensionsMap($this->sTargetEnvironment, true);
|
||||
}
|
||||
return $this->oItopExtensionsMap;
|
||||
}
|
||||
|
||||
public function GetAutoSelectModules(): array {
|
||||
return $this->aAutoSelectModules;
|
||||
}
|
||||
@@ -69,14 +93,6 @@ class InstallationFileService {
|
||||
return $this->aUnSelectedModules;
|
||||
}
|
||||
|
||||
public function Init(): void {
|
||||
clearstatcache();
|
||||
|
||||
$this->ProcessDefaultModules();
|
||||
$this->ProcessInstallationChoices();
|
||||
$this->ProcessAutoSelectModules();
|
||||
}
|
||||
|
||||
public function ProcessInstallationChoices(): void {
|
||||
$oXMLParameters = new XMLParameters($this->sInstallationPath);
|
||||
$aSteps = $oXMLParameters->Get('steps', []);
|
||||
@@ -274,4 +290,76 @@ class InstallationFileService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CanChooseUnpackageExtension(iTopExtension $oExtension) : bool {
|
||||
if ($oExtension->sSource === iTopExtension::SOURCE_REMOTE){
|
||||
SetupLog::Info("Data Extension can be selected", null, ['extension' => $oExtension->sCode]);
|
||||
return true;
|
||||
}
|
||||
|
||||
$bSelectable = $this->bInstallationOptionalChoicesChecked && ($oExtension->sSource === iTopExtension::SOURCE_MANUAL);
|
||||
if ($bSelectable){
|
||||
SetupLog::Info("Manual Extension can be selected", null, ['extension' => $oExtension->sCode]);
|
||||
} else {
|
||||
SetupLog::Debug("Manual Extension can NOT be selected", null, ['extension' => $oExtension->sCode]);
|
||||
}
|
||||
|
||||
return $bSelectable;
|
||||
}
|
||||
|
||||
public function ProcessExtensionModulesNotSpecifiedInChoices() {
|
||||
/** @var \iTopExtension $oExtension */
|
||||
foreach($this->GetItopExtensionsMap()->GetAllExtensions() as $oExtension) {
|
||||
if (in_array($oExtension->sCode, $this->aAfterComputationSelectedExtensions)){
|
||||
//extension already processed in installation.xml
|
||||
SetupLog::Info("Extension already processed via installation choices", null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
]) ;
|
||||
continue;
|
||||
}
|
||||
if ($this->CanChooseUnpackageExtension($oExtension)){
|
||||
if (($oExtension->bVisible) && (count($oExtension->aMissingDependencies) === 0)) {
|
||||
$aCurrentModules = [];
|
||||
$aUnselectableModules = [];
|
||||
$bIsExtensionSelectable = true;
|
||||
foreach ($oExtension->aModules as $sModuleId) {
|
||||
if (array_key_exists($sModuleId, $this->aSelectedModules)) {
|
||||
//already selected
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists($sModuleId, $this->aUnSelectedModules)) {
|
||||
$aUnselectableModules[] = $sModuleId;
|
||||
|
||||
//already unselected
|
||||
$bIsExtensionSelectable = false;
|
||||
} else {
|
||||
$aCurrentModules[$sModuleId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($bIsExtensionSelectable) {
|
||||
SetupLog::Debug("Add modules from unpackaged extension", null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
'source' => $oExtension->sSource,
|
||||
'modules to add' => array_keys($aCurrentModules),
|
||||
]);
|
||||
$this->aSelectedModules = array_merge($this->aSelectedModules, $aCurrentModules);
|
||||
$this->aAfterComputationSelectedExtensions[] = $oExtension->sCode;
|
||||
} else {
|
||||
SetupLog::Warning("Unpackaged extension can not be selected due to modules incompatible with installation choices",
|
||||
null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
'source' => $oExtension->sSource,
|
||||
'modules' => array_keys($aCurrentModules),
|
||||
'unselectable modules' => $aUnselectableModules,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user