From ebd0ae85a4ce674b0972c8b675b5e57da81691fe Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 23 Jun 2016 08:14:43 +0000 Subject: [PATCH] Code refactoring : fix of #876 implemented in 2.0.3 as [r3161], moved to a place where it will fix other implementations of the setup SVN:trunk[4252] --- setup/applicationinstaller.class.inc.php | 11 ++--------- setup/runtimeenv.class.inc.php | 8 ++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index 094a81bfbe..d099269fa8 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -1000,10 +1000,6 @@ class ApplicationInstaller } $oConfig->Set('source_dir', $sSourceDir); - // Have it work fine even if the DB has been set in read-only mode for the users - $iPrevAccessMode = $oConfig->Get('access_mode'); - $oConfig->Set('access_mode', ACCESS_FULL); - // Record which modules are installed... $oProductionEnv = new RunTimeEnvironment($sTargetEnvironment); $oProductionEnv->InitDataModel($oConfig, true); // load data model and connect to the database @@ -1011,11 +1007,8 @@ class ApplicationInstaller if (!$oProductionEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModules, $sModulesDir)) { throw new Exception("Failed to record the installation information"); - } - - // Restore the previous access mode - $oConfig->Set('access_mode', $iPrevAccessMode); - + } + // Make sure the root configuration directory exists if (!file_exists(APPCONF)) { diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index 7bee178698..4848daa9a8 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -596,6 +596,10 @@ class RunTimeEnvironment public function RecordInstallation(Config $oConfig, $sDataModelVersion, $aSelectedModules, $sModulesRelativePath, $sShortComment = null) { + // Have it work fine even if the DB has been set in read-only mode for the users + $iPrevAccessMode = $oConfig->Get('access_mode'); + $oConfig->Set('access_mode', ACCESS_FULL); + if ($sShortComment === null) { $sShortComment = 'Done by the setup program'; @@ -665,6 +669,10 @@ class RunTimeEnvironment $oInstallRec->Set('installed', $iInstallationTime); $oInstallRec->DBInsertNoReload(); } + + // Restore the previous access mode + $oConfig->Set('access_mode', $iPrevAccessMode); + // Database is created, installation has been tracked into it return true; }