diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 6050a9e46..57c590af7 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -20,7 +20,7 @@ define('ITOP_APPLICATION', 'iTop'); define('ITOP_APPLICATION_SHORT', 'iTop'); define('ITOP_VERSION', '2.5.0-beta'); -define('ITOP_REVISION', 'svn'); +define('ITOP_REVISION', '3804'); define('ITOP_BUILD_DATE', '$WCNOW$'); define('ACCESS_USER_WRITE', 1); @@ -1176,9 +1176,19 @@ class Config } - public function Get($sPropCode) + public function Get($sPropCode, $sModule = null) { - return $this->m_aSettings[$sPropCode]['value']; + $sRetValue = ''; + if(empty($sModule)) + { + $sRetValue = $this->m_aSettings[$sPropCode]['value']; + } + else + { + $sRetValue = $this->m_aModuleSettings[$sModule][$sPropCode]; + + } + return $sRetValue; } /** diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index d8263c72e..5f9092969 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -40,7 +40,8 @@ class ApplicationInstaller const ERROR = 2; const WARNING = 3; const INFO = 4; - + + /** @var \PHPParameters */ protected $oParams; protected static $bMetaModelStarted = false; @@ -180,8 +181,8 @@ class ApplicationInstaller $aDBParams = $this->GetParamValues($this->oParams); $oTempConfig = new Config(); $oTempConfig->UpdateFromParams($aDBParams); - - self::DoBackup($oTempConfig, $sDestination, $sSourceConfigFile); + $sMySQLBinDir = $this->oParams->Get('mysql_bindir', null); + self::DoBackup($oTempConfig, $sDestination, $sSourceConfigFile, $sMySQLBinDir); $aResult = array( 'status' => self::OK, @@ -428,10 +429,14 @@ class ApplicationInstaller * * @since 2.5 uses a {@link Config} object to store DB parameters */ - protected static function DoBackup($oConfig, $sBackupFileFormat, $sSourceConfigFile) + protected static function DoBackup($oConfig, $sBackupFileFormat, $sSourceConfigFile, $sMySQLBinDir = null) { $oBackup = new SetupDBBackup($oConfig); $sTargetFile = $oBackup->MakeName($sBackupFileFormat); + if (!empty($sMySQLBinDir)) + { + $oBackup->SetMySQLBinDir($sMySQLBinDir); + } $oBackup->CreateCompressedBackup($sTargetFile, $sSourceConfigFile); } diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index 123df0fe5..bea2fc215 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -677,6 +677,7 @@ if (class_exists('ZipArchive')) // The setup must be able to start even if the " * * @uses mysqldump -V Sample return value : mysqldump Ver 10.13 Distrib 5.7.19, for Win64 (x86_64) * @since 2.5 needed to check compatibility with utf8mb4 (N°1001) + * @throws \BackupException */ private static function GetMysqldumpVersion($sMysqldumpCommand) { @@ -684,6 +685,11 @@ if (class_exists('ZipArchive')) // The setup must be able to start even if the " $aOutput = array(); exec($sCommand, $aOutput, $iRetCode); + if ($iRetCode != 0) + { + throw new BackupException("mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and located at : $sMysqldumpCommand"); + } + $sMysqldumpOutput = $aOutput[0]; $aDumpVersionMatchResults = array(); preg_match('/Distrib (\d+\.\d+\.\d+)/', $sMysqldumpOutput, $aDumpVersionMatchResults); diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 59a7dfb68..18986e3e1 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -417,7 +417,7 @@ class SetupUtils * @return array An array of CheckResults objects * @internal param Page $oP The page used only for its 'log' method */ - static function CheckBackupPrerequisites($sDestDir) + static function CheckBackupPrerequisites($sDestDir, $sMySQLBinDir = null) { $aResult = array(); SetupPage::log('Info - CheckBackupPrerequisites'); @@ -445,7 +445,11 @@ class SetupUtils } // availability of mysqldump - $sMySQLBinDir = utils::ReadParam('mysql_bindir', '', true); + if (empty($sMySQLBinDir) && null != MetaModel::GetConfig()) + { + $sMySQLBinDir = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''); + } + if (empty($sMySQLBinDir)) { $sMySQLDump = 'mysqldump'; @@ -472,7 +476,7 @@ class SetupUtils else { // Unfortunately $aOutput is not really usable since we don't know its encoding (character set) - $aResult[] = new CheckResult(CheckResult::ERROR, "mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and in the path"); + $aResult[] = new CheckResult(CheckResult::ERROR, "mysqldump could not be executed (retcode=$iRetCode): Please make sure it is installed and " . (empty($sMySQLBinDir) ? "in the path" : "located at : $sMySQLDump")); } foreach($aOutput as $sLine) { @@ -833,6 +837,7 @@ class SetupUtils 'db_tls_enabled' => $oPrevConf->Get('db_tls.enabled'), 'db_tls_ca' => $oPrevConf->Get('db_tls.ca'), 'graphviz_path' => $oPrevConf->Get('graphviz_path'), + 'mysql_bindir' => $oPrevConf->Get('mysql_bindir', 'itop-backup'), ); } diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index 1802ca637..b1ebb97c9 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -209,6 +209,7 @@ class WizStepInstallOrUpgrade extends WizardStep $sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', ''); $sTlsEnabled = $this->oWizard->GetParameter('db_tls_enabled', false); $sTlsCA = $this->oWizard->GetParameter('db_tls_ca', ''); + $sMySQLBinDir = $this->oWizard->GetParameter('mysql_bindir', null); $sPreviousVersionDir = ''; if ($sInstallMode == '') { @@ -226,6 +227,8 @@ class WizStepInstallOrUpgrade extends WizardStep $sTlsEnabled = $aPreviousInstance['db_tls_enabled']; $sTlsCA = $aPreviousInstance['db_tls_ca']; $this->oWizard->SaveParameter('graphviz_path', $aPreviousInstance['graphviz_path']); + $sMySQLBinDir = $aPreviousInstance['mysql_bindir']; + $this->oWizard->SaveParameter('mysql_bindir', $aPreviousInstance['mysql_bindir']); $sPreviousVersionDir = APPROOT; } else @@ -253,7 +256,7 @@ class WizStepInstallOrUpgrade extends WizardStep SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sTlsEnabled, $sTlsCA, null); - $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath); + $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir); $bCanBackup = true; $sMySQLDumpMessage = ''; foreach($aBackupChecks as $oCheck) @@ -2343,6 +2346,7 @@ EOF 'sample_data' => ($this->oWizard->GetParameter('sample_data', '') == 'yes') ? true : false , 'old_addon' => $this->oWizard->GetParameter('old_addon', false), // whether or not to use the "old" userrights profile addon 'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true), + 'mysql_bindir' => $this->oWizard->GetParameter('mysql_bindir'), ); if ($sBackupDestination != '')