mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8981 setup wizard: cleanup config use in setup wizard
This commit is contained in:
@@ -2685,14 +2685,13 @@ class Config
|
||||
*
|
||||
* @param array $aParamValues
|
||||
* @param ?string $sModulesDir
|
||||
* @param bool $bPreserveModuleSettings
|
||||
*
|
||||
* @return void The current object is modified directly
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function UpdateFromParams($aParamValues, $sModulesDir = null, $bPreserveModuleSettings = false)
|
||||
public function UpdateFromParams($aParamValues, $sModulesDir = null)
|
||||
{
|
||||
if (isset($aParamValues['application_path'])) {
|
||||
$this->Set('app_root_url', $aParamValues['application_path']);
|
||||
@@ -2740,7 +2739,10 @@ class Config
|
||||
} else {
|
||||
$aSelectedModules = null;
|
||||
}
|
||||
$this->UpdateIncludes($sModulesDir, $aSelectedModules);
|
||||
|
||||
if (! is_null($sModulesDir)) {
|
||||
$this->UpdateIncludes($sModulesDir, $aSelectedModules);
|
||||
}
|
||||
|
||||
if (isset($aParamValues['source_dir'])) {
|
||||
$this->Set('source_dir', $aParamValues['source_dir']);
|
||||
@@ -2758,12 +2760,8 @@ class Config
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function UpdateIncludes($sModulesDir, $aSelectedModules = null)
|
||||
public function UpdateIncludes(string $sModulesDir, $aSelectedModules = null)
|
||||
{
|
||||
if ($sModulesDir === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the arrays below with default values for the application...
|
||||
$oEmptyConfig = new Config('dummy_file', false); // Do NOT load any config file, just set the default values
|
||||
$aAddOns = $oEmptyConfig->GetAddOns();
|
||||
|
||||
@@ -46,6 +46,8 @@ class ApplicationInstaller
|
||||
protected $oParams;
|
||||
protected static $bMetaModelStarted = false;
|
||||
|
||||
protected Config $oConfig;
|
||||
|
||||
/**
|
||||
* @param \Parameters $oParams
|
||||
*
|
||||
@@ -57,9 +59,9 @@ class ApplicationInstaller
|
||||
$this->oParams = $oParams;
|
||||
|
||||
$aParamValues = $oParams->GetParamForConfigArray();
|
||||
$oConfig = new Config();
|
||||
$oConfig->UpdateFromParams($aParamValues, null);
|
||||
utils::SetConfig($oConfig);
|
||||
$this->oConfig = new Config();
|
||||
$this->oConfig->UpdateFromParams($aParamValues);
|
||||
utils::SetConfig($this->oConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,11 +240,8 @@ class ApplicationInstaller
|
||||
// __DB__-%Y-%m-%d
|
||||
$sDestination = $aPreinstall['backup']['destination'];
|
||||
$sSourceConfigFile = $aPreinstall['backup']['configuration_file'];
|
||||
$aDBParams = $this->oParams->GetParamForConfigArray();
|
||||
$oTempConfig = new Config();
|
||||
$oTempConfig->UpdateFromParams($aDBParams);
|
||||
$sMySQLBinDir = $this->oParams->Get('mysql_bindir', null);
|
||||
self::DoBackup($oTempConfig, $sDestination, $sSourceConfigFile, $sMySQLBinDir);
|
||||
self::DoBackup($this->oConfig, $sDestination, $sSourceConfigFile, $sMySQLBinDir);
|
||||
|
||||
$aResult = [
|
||||
'status' => self::OK,
|
||||
@@ -565,15 +564,9 @@ class ApplicationInstaller
|
||||
$sConfigFilePath = utils::GetConfigFilePath($sEnvironment);
|
||||
if (is_file($sConfigFilePath)) {
|
||||
$oConfig = new Config($sConfigFilePath);
|
||||
} else {
|
||||
$oConfig = null;
|
||||
}
|
||||
|
||||
if (false === is_null($oConfig)) {
|
||||
$oConfig->UpdateFromParams($aParamValues);
|
||||
SetupUtils::EnterMaintenanceMode($oConfig);
|
||||
}
|
||||
|
||||
SetupUtils::EnterMaintenanceMode($oConfig);
|
||||
}
|
||||
|
||||
if (!is_dir($sTargetPath)) {
|
||||
@@ -682,11 +675,6 @@ class ApplicationInstaller
|
||||
$oConfig = new Config();
|
||||
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
|
||||
|
||||
if ($bOldAddon) {
|
||||
// Old version of the add-on for backward compatibility with pre-2.0 data models
|
||||
$oConfig->SetAddons([]);
|
||||
}
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
$oProductionEnv->InitDataModel($oConfig, true); // load data model only
|
||||
|
||||
@@ -860,11 +848,6 @@ class ApplicationInstaller
|
||||
$oConfig = new Config();
|
||||
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
|
||||
|
||||
if ($bOldAddon) {
|
||||
// Old version of the add-on for backward compatibility with pre-2.0 data models
|
||||
$oConfig->SetAddons([]);
|
||||
}
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
$oProductionEnv->InitDataModel($oConfig, true); // load data model and connect to the database
|
||||
$oContextTag = new ContextTag(ContextTag::TAG_SETUP);
|
||||
@@ -922,11 +905,6 @@ class ApplicationInstaller
|
||||
$oConfig = new Config();
|
||||
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
|
||||
|
||||
if ($bOldAddon) {
|
||||
// Old version of the add-on for backward compatibility with pre-2.0 data models
|
||||
$oConfig->SetAddons([]);
|
||||
}
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
|
||||
//Load the MetaModel if needed (asynchronous mode)
|
||||
@@ -980,12 +958,10 @@ class ApplicationInstaller
|
||||
$aParamValues['selected_modules'] = implode(',', $aSelectedModuleCodes);
|
||||
$sMode = $aParamValues['mode'];
|
||||
|
||||
$bPreserveModuleSettings = false;
|
||||
if ($sMode == 'upgrade') {
|
||||
try {
|
||||
$oOldConfig = new Config($sPreviousConfigFile);
|
||||
$oConfig = clone($oOldConfig);
|
||||
$bPreserveModuleSettings = true;
|
||||
} catch (Exception $e) {
|
||||
// In case the previous configuration is corrupted... start with a blank new one
|
||||
$oConfig = new Config();
|
||||
@@ -999,11 +975,7 @@ class ApplicationInstaller
|
||||
|
||||
$oConfig->Set('access_mode', ACCESS_FULL);
|
||||
// Final config update: add the modules
|
||||
$oConfig->UpdateFromParams($aParamValues, $sModulesDir, $bPreserveModuleSettings);
|
||||
if ($bOldAddon) {
|
||||
// Old version of the add-on for backward compatibility with pre-2.0 data models
|
||||
$oConfig->SetAddons([]);
|
||||
}
|
||||
$oConfig->UpdateFromParams($aParamValues, $sModulesDir);
|
||||
|
||||
// Record which modules are installed...
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
|
||||
@@ -1570,7 +1570,7 @@ JS
|
||||
|
||||
$aParamValues = $oWizard->GetParamForConfigArray();
|
||||
$aParamValues['source_dir'] = $sRelativeSourceDir;
|
||||
$oConfig->UpdateFromParams($aParamValues, null);
|
||||
$oConfig->UpdateFromParams($aParamValues);
|
||||
|
||||
return $oConfig;
|
||||
}
|
||||
@@ -1627,7 +1627,7 @@ JS
|
||||
|
||||
$aParamValues = $oWizard->GetParamForConfigArray();
|
||||
$aParamValues['source_dir'] = '';
|
||||
$oConfig->UpdateFromParams($aParamValues, null);
|
||||
$oConfig->UpdateFromParams($aParamValues);
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment();
|
||||
return $oProductionEnv->GetApplicationVersion($oConfig);
|
||||
|
||||
Reference in New Issue
Block a user