diff --git a/datamodels/2.x/itop-attachments/module.itop-attachments.php b/datamodels/2.x/itop-attachments/module.itop-attachments.php index 19593f0b7..e348615ac 100644 --- a/datamodels/2.x/itop-attachments/module.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/module.itop-attachments.php @@ -97,14 +97,14 @@ if (!class_exists('AttachmentInstaller')) $iCount = CMDBSource::QueryToScalar($sCountQuery); if ($iCount > 0) { - SetupPage::log_info("Cleanup of orphan attachments that cannot be migrated to the new ObjKey model: $iCount record(s) must be deleted."); + SetupLog::Info("Cleanup of orphan attachments that cannot be migrated to the new ObjKey model: $iCount record(s) must be deleted."); $sRepairQuery = "DELETE FROM `$sTableName` WHERE (`item_id`='' OR `item_id` IS NULL)"; $iRet = CMDBSource::Query($sRepairQuery); // Throws an exception in case of error - SetupPage::log_info("Cleanup of orphan attachments successfully completed."); + SetupLog::Info("Cleanup of orphan attachments successfully completed."); } else { - SetupPage::log_info("No orphan attachment found."); + SetupLog::Info("No orphan attachment found."); } } } @@ -121,12 +121,12 @@ if (!class_exists('AttachmentInstaller')) // get the org_id from the container object // // Prerequisite: change null into 0 (workaround to the fact that we cannot use IS NULL in OQL) - SetupPage::log_info("Initializing attachment/item_org_id - null to zero"); + SetupLog::Info("Initializing attachment/item_org_id - null to zero"); $sTableName = MetaModel::DBGetTable('Attachment'); $sRepair = "UPDATE `$sTableName` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL"; CMDBSource::Query($sRepair); - SetupPage::log_info("Initializing attachment/item_org_id - zero to the container"); + SetupLog::Info("Initializing attachment/item_org_id - zero to the container"); $oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_org_id = 0"); $oSet = new DBObjectSet($oSearch); $iUpdated = 0; @@ -140,7 +140,7 @@ if (!class_exists('AttachmentInstaller')) } } - SetupPage::log_info("Initializing attachment/item_org_id - $iUpdated records have been adjusted"); + SetupLog::Info("Initializing attachment/item_org_id - $iUpdated records have been adjusted"); } } } diff --git a/datamodels/2.x/itop-hub-connector/ajax.php b/datamodels/2.x/itop-hub-connector/ajax.php index f9e44d81e..31a388d30 100644 --- a/datamodels/2.x/itop-hub-connector/ajax.php +++ b/datamodels/2.x/itop-hub-connector/ajax.php @@ -182,218 +182,218 @@ try switch ($sOperation) { case 'check_before_backup': - require_once (APPROOT.'/application/startup.inc.php'); - require_once (APPROOT.'/application/loginwebpage.class.inc.php'); - LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) - - $sDBBackupPath = APPROOT.'data/backups/manual'; - $aChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath); - $bFailed = false; - foreach ($aChecks as $oCheckResult) - { - if ($oCheckResult->iSeverity==CheckResult::ERROR) - { - $bFailed = true; - ReportError($oCheckResult->sLabel, -2); - } - } - if (!$bFailed) - { - // Continue the checks - $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); - if ($fFreeSpace!==false) - { - $sMessage = Dict::Format('iTopHub:BackupFreeDiskSpaceIn', SetupUtils::HumanReadableSize($fFreeSpace), dirname($sDBBackupPath)); - ReportSuccess($sMessage); - } - else - { - ReportError(Dict::S('iTopHub:FailedToCheckFreeDiskSpace'), -1); - } - } - break; - - case 'do_backup': - require_once (APPROOT.'/application/startup.inc.php'); - require_once (APPROOT.'/application/loginwebpage.class.inc.php'); - LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) - - try - { - if (MetaModel::GetConfig()->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode'); - SetupPage::log_info('Backup starts...'); - set_time_limit(0); - $sBackupPath = APPROOT.'/data/backups/manual/backup-'; - $iSuffix = 1; - $sSuffix = ''; - // Generate a unique name... - do - { - $sBackupFile = $sBackupPath.date('Y-m-d-His').$sSuffix; - $sSuffix = '-'.$iSuffix; - $iSuffix++ ; - } - while (file_exists($sBackupFile)); - - $oBackup = DoBackup($sBackupFile); - $aErrors = $oBackup->GetErrors(); - if (count($aErrors)>0) - { - SetupPage::log_error('Backup failed.'); - SetupPage::log_error(implode("\n", $aErrors)); - ReportError(Dict::S('iTopHub:BackupFailed'), -1, $aErrors); - } - else - { - SetupPage::log_info('Backup successfully completed.'); - ReportSuccess(Dict::S('iTopHub:BackupOk')); - } - } - catch (Exception $e) - { - SetupPage::log_error($e->getMessage()); - ReportError($e->getMessage(), $e->getCode()); - } - break; - - case 'compile': - SetupPage::log_info('Deployment starts...'); - $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); - if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) - { - throw new SecurityException(Dict::S('iTopHub:FailAuthent')); - } - // First step: prepare the datamodel, if it fails, roll-back - $aSelectedExtensionCodes = utils::ReadParam('extension_codes', array()); - $aSelectedExtensionDirs = utils::ReadParam('extension_dirs', array()); - - $oRuntimeEnv = new HubRunTimeEnvironment('production', false); // use a temp environment: production-build - $oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs); - - $oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE); - if ($oConfig->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode'); - - $aSelectModules = $oRuntimeEnv->CompileFrom('production', false); // WARNING symlinks does not seem to be compatible with manual Commit - - $oRuntimeEnv->UpdateIncludes($oConfig); - - $oRuntimeEnv->InitDataModel($oConfig, true /* model only */); - - // Safety check: check the inter dependencies, will throw an exception in case of inconsistency - $oRuntimeEnv->AnalyzeInstallation($oConfig, $oRuntimeEnv->GetBuildDir(), true); - - $oRuntimeEnv->CheckMetaModel(); // Will throw an exception if a problem is detected - - // Everything seems Ok so far, commit in env-production! - $oRuntimeEnv->WriteConfigFileSafe($oConfig); - $oRuntimeEnv->Commit(); - - // Report the success in a way that will be detected by the ajax caller - SetupPage::log_info('Compilation completed...'); - ReportSuccess('Ok'); // No access to Dict::S here - break; - - case 'move_to_production': - // Second step: update the schema and the data - // Everything happening below is based on env-production - $oRuntimeEnv = new RunTimeEnvironment('production', true); - - try - { - SetupPage::log_info('Move to production starts...'); - $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); - if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) - { - throw new SecurityException(Dict::S('iTopHub:FailAuthent')); - } - unlink(APPROOT.'data/hub/compile_authent'); - // Load the "production" config file to clone & update it - $oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE); - SetupUtils::EnterReadOnlyMode($oConfig); + require_once (APPROOT.'/application/startup.inc.php'); + require_once (APPROOT.'/application/loginwebpage.class.inc.php'); + LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) - $oRuntimeEnv->InitDataModel($oConfig, true /* model only */); - - $aAvailableModules = $oRuntimeEnv->AnalyzeInstallation($oConfig, $oRuntimeEnv->GetBuildDir(), true); - - $aSelectedModules = array(); - foreach ($aAvailableModules as $sModuleId => $aModule) + $sDBBackupPath = APPROOT.'data/backups/manual'; + $aChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath); + $bFailed = false; + foreach ($aChecks as $oCheckResult) { - if (($sModuleId == ROOT_MODULE) || ($sModuleId == DATAMODEL_MODULE)) + if ($oCheckResult->iSeverity==CheckResult::ERROR) { - continue; + $bFailed = true; + ReportError($oCheckResult->sLabel, -2); + } + } + if (!$bFailed) + { + // Continue the checks + $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); + if ($fFreeSpace!==false) + { + $sMessage = Dict::Format('iTopHub:BackupFreeDiskSpaceIn', SetupUtils::HumanReadableSize($fFreeSpace), dirname($sDBBackupPath)); + ReportSuccess($sMessage); } else { - $aSelectedModules[] = $sModuleId; + ReportError(Dict::S('iTopHub:FailedToCheckFreeDiskSpace'), -1); } } - - $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'BeforeDatabaseCreation'); - - $oRuntimeEnv->CreateDatabaseStructure($oConfig, 'upgrade'); - - $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDatabaseCreation'); - - $oRuntimeEnv->UpdatePredefinedObjects(); - - $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDatabaseSetup'); - - $oRuntimeEnv->LoadData($aAvailableModules, $aSelectedModules, false /* no sample data*/); + break; + + case 'do_backup': + require_once (APPROOT.'/application/startup.inc.php'); + require_once (APPROOT.'/application/loginwebpage.class.inc.php'); + LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin) - $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDataLoad'); - - // Record the installation so that the "about box" knows about the installed modules - $sDataModelVersion = $oRuntimeEnv->GetCurrentDataModelVersion(); - - $oExtensionsMap = new iTopExtensionsMap(); - - // Default choices = as before - $oExtensionsMap->LoadChoicesFromDatabase($oConfig); - foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) + try { - // Plus all "remote" extensions - if ($oExtension->sSource==iTopExtension::SOURCE_REMOTE) + if (MetaModel::GetConfig()->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode'); + SetupLog::Info('Backup starts...'); + set_time_limit(0); + $sBackupPath = APPROOT.'/data/backups/manual/backup-'; + $iSuffix = 1; + $sSuffix = ''; + // Generate a unique name... + do { - $oExtensionsMap->MarkAsChosen($oExtension->sCode); + $sBackupFile = $sBackupPath.date('Y-m-d-His').$sSuffix; + $sSuffix = '-'.$iSuffix; + $iSuffix++ ; + } + while (file_exists($sBackupFile)); + + $oBackup = DoBackup($sBackupFile); + $aErrors = $oBackup->GetErrors(); + if (count($aErrors)>0) + { + SetupLog::Error('Backup failed.'); + SetupLog::Error(implode("\n", $aErrors)); + ReportError(Dict::S('iTopHub:BackupFailed'), -1, $aErrors); + } + else + { + SetupLog::Info('Backup successfully completed.'); + ReportSuccess(Dict::S('iTopHub:BackupOk')); } } - $aSelectedExtensionCodes = array(); - foreach ($oExtensionsMap->GetChoices() as $oExtension) + catch (Exception $e) { - $aSelectedExtensionCodes[] = $oExtension->sCode; + SetupLog::Error($e->getMessage()); + ReportError($e->getMessage(), $e->getCode()); } - $aSelectedExtensions = $oExtensionsMap->GetChoices(); - $oRuntimeEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModules, $aSelectedExtensionCodes, 'Done by the iTop Hub Connector'); - + break; + + case 'compile': + SetupLog::Info('Deployment starts...'); + $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); + if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) + { + throw new SecurityException(Dict::S('iTopHub:FailAuthent')); + } + // First step: prepare the datamodel, if it fails, roll-back + $aSelectedExtensionCodes = utils::ReadParam('extension_codes', array()); + $aSelectedExtensionDirs = utils::ReadParam('extension_dirs', array()); + + $oRuntimeEnv = new HubRunTimeEnvironment('production', false); // use a temp environment: production-build + $oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs); + + $oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE); + if ($oConfig->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode'); + + $aSelectModules = $oRuntimeEnv->CompileFrom('production', false); // WARNING symlinks does not seem to be compatible with manual Commit + + $oRuntimeEnv->UpdateIncludes($oConfig); + + $oRuntimeEnv->InitDataModel($oConfig, true /* model only */); + + // Safety check: check the inter dependencies, will throw an exception in case of inconsistency + $oRuntimeEnv->AnalyzeInstallation($oConfig, $oRuntimeEnv->GetBuildDir(), true); + + $oRuntimeEnv->CheckMetaModel(); // Will throw an exception if a problem is detected + + // Everything seems Ok so far, commit in env-production! + $oRuntimeEnv->WriteConfigFileSafe($oConfig); + $oRuntimeEnv->Commit(); + // Report the success in a way that will be detected by the ajax caller - SetupPage::log_info('Deployment successfully completed.'); - ReportSuccess(Dict::S('iTopHub:CompiledOK')); - } - catch (Exception $e) - { - if(file_exists(APPROOT.'data/hub/compile_authent')) + SetupLog::Info('Compilation completed...'); + ReportSuccess('Ok'); // No access to Dict::S here + break; + + case 'move_to_production': + // Second step: update the schema and the data + // Everything happening below is based on env-production + $oRuntimeEnv = new RunTimeEnvironment('production', true); + + try { + SetupLog::Info('Move to production starts...'); + $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); + if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) + { + throw new SecurityException(Dict::S('iTopHub:FailAuthent')); + } unlink(APPROOT.'data/hub/compile_authent'); + // Load the "production" config file to clone & update it + $oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE); + SetupUtils::EnterReadOnlyMode($oConfig); + + $oRuntimeEnv->InitDataModel($oConfig, true /* model only */); + + $aAvailableModules = $oRuntimeEnv->AnalyzeInstallation($oConfig, $oRuntimeEnv->GetBuildDir(), true); + + $aSelectedModules = array(); + foreach ($aAvailableModules as $sModuleId => $aModule) + { + if (($sModuleId == ROOT_MODULE) || ($sModuleId == DATAMODEL_MODULE)) + { + continue; + } + else + { + $aSelectedModules[] = $sModuleId; + } + } + + $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'BeforeDatabaseCreation'); + + $oRuntimeEnv->CreateDatabaseStructure($oConfig, 'upgrade'); + + $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDatabaseCreation'); + + $oRuntimeEnv->UpdatePredefinedObjects(); + + $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDatabaseSetup'); + + $oRuntimeEnv->LoadData($aAvailableModules, $aSelectedModules, false /* no sample data*/); + + $oRuntimeEnv->CallInstallerHandlers($aAvailableModules, $aSelectedModules, 'AfterDataLoad'); + + // Record the installation so that the "about box" knows about the installed modules + $sDataModelVersion = $oRuntimeEnv->GetCurrentDataModelVersion(); + + $oExtensionsMap = new iTopExtensionsMap(); + + // Default choices = as before + $oExtensionsMap->LoadChoicesFromDatabase($oConfig); + foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) + { + // Plus all "remote" extensions + if ($oExtension->sSource==iTopExtension::SOURCE_REMOTE) + { + $oExtensionsMap->MarkAsChosen($oExtension->sCode); + } + } + $aSelectedExtensionCodes = array(); + foreach ($oExtensionsMap->GetChoices() as $oExtension) + { + $aSelectedExtensionCodes[] = $oExtension->sCode; + } + $aSelectedExtensions = $oExtensionsMap->GetChoices(); + $oRuntimeEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModules, $aSelectedExtensionCodes, 'Done by the iTop Hub Connector'); + + // Report the success in a way that will be detected by the ajax caller + SetupLog::Info('Deployment successfully completed.'); + ReportSuccess(Dict::S('iTopHub:CompiledOK')); + } + catch (Exception $e) + { + if(file_exists(APPROOT.'data/hub/compile_authent')) + { + unlink(APPROOT.'data/hub/compile_authent'); + } + // Note: at this point, the dictionnary is not necessarily loaded + SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage()); + SetupLog::Error('Debug trace: '.$e->getTraceAsString()); + ReportError($e->getMessage(), $e->getCode()); + } + finally + { + SetupUtils::ExitReadOnlyMode(); } - // Note: at this point, the dictionnary is not necessarily loaded - SetupPage::log_error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage()); - SetupPage::log_error('Debug trace: '.$e->getTraceAsString()); - ReportError($e->getMessage(), $e->getCode()); - } - finally - { - SetupUtils::ExitReadOnlyMode(); - } break; default: - ReportError("Invalid operation: '$sOperation'", -1); + ReportError("Invalid operation: '$sOperation'", -1); } } catch (Exception $e) { - SetupPage::log_error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage()); - SetupPage::log_error('Debug trace: '.$e->getTraceAsString()); + SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage()); + SetupLog::Error('Debug trace: '.$e->getTraceAsString()); utils::PopArchiveMode(); diff --git a/setup/ajax.dataloader.php b/setup/ajax.dataloader.php index 9d1b01f08..017749712 100644 --- a/setup/ajax.dataloader.php +++ b/setup/ajax.dataloader.php @@ -48,7 +48,7 @@ if (empty($sMemoryLimit)) // On some PHP installations, memory_limit does not exist as a PHP setting! // (encountered on a 5.2.0 under Windows) // In that case, ini_set will not work, let's keep track of this and proceed with the data load - SetupPage::log_info("No memory limit has been defined in this instance of PHP"); + SetupLog::Info("No memory limit has been defined in this instance of PHP"); } else { @@ -59,11 +59,11 @@ else { if (ini_set('memory_limit', SAFE_MINIMUM_MEMORY) === FALSE) { - SetupPage::log_error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself."); + SetupLog::Error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself."); } else { - SetupPage::log_info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY."."); + SetupLog::Info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY."."); } } } @@ -89,7 +89,7 @@ function ShutdownCallback() $errline = $error["line"]; $errstr = $error["message"]; $sLogMessage = "PHP error occured : msg=$errstr, no=$errno, file=$errfile, line=$errline"; - SetupPage::log_error("Setup error: $sLogMessage"); + SetupLog::Error("Setup error: $sLogMessage"); echo '<'.PHP_FATAL_ERROR_TAG.'>'.$sLogMessage.''.PHP_FATAL_ERROR_TAG.'>'; } @@ -188,17 +188,17 @@ catch(Exception $e) header("HTTP/1.0 500 Internal server error."); echo "
An error happened while processing the installation:
\n"; echo ''.$e."
\n"; - SetupPage::log_error("An error happened while processing the installation: ".$e); + SetupLog::Error("An error happened while processing the installation: ".$e); } if (function_exists('memory_get_peak_usage')) { if ($sOperation == 'file') { - SetupPage::log_info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage()); + SetupLog::Info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage()); } else { - SetupPage::log_info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage()); + SetupLog::Info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage()); } } \ No newline at end of file diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index 004094b1e..c4a4e5412 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -189,7 +189,7 @@ class ApplicationInstaller try { $fStart = microtime(true); - SetupPage::log_info("##### STEP {$sStep} start"); + SetupLog::Info("##### STEP {$sStep} start"); $this->EnterReadOnlyMode(); switch ($sStep) { @@ -209,7 +209,7 @@ class ApplicationInstaller $this->oParams->ToXML($oDoc, null, 'installation'); $sXML = $oDoc->saveXML(); $sSafeXml = preg_replace("|Done.
\n"; @@ -475,12 +475,12 @@ class ModuleDiscovery catch(ParseError $e) { // PHP 7 - SetupPage::log_warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()." at line ".$e->getLine()); + SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()." at line ".$e->getLine()); } catch(Exception $e) { // Continue... - SetupPage::log_warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()); + SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()); } } } @@ -503,27 +503,27 @@ class SetupWebPage extends ModuleDiscovery // For backward compatibility with old modules... public static function log_error($sText) { - SetupPage::log_error($sText); + SetupLog::Error($sText); } public static function log_warning($sText) { - SetupPage::log_warning($sText); + SetupLog::Warning($sText); } public static function log_info($sText) { - SetupPage::log_info($sText); + SetupLog::Info($sText); } public static function log_ok($sText) { - SetupPage::log_ok($sText); + SetupLog::Ok($sText); } public static function log($sText) { - SetupPage::log($sText); + SetupLog::Ok($sText); } } diff --git a/setup/moduleinstaller.class.inc.php b/setup/moduleinstaller.class.inc.php index 3880ae40b..89177b6fc 100644 --- a/setup/moduleinstaller.class.inc.php +++ b/setup/moduleinstaller.class.inc.php @@ -95,12 +95,12 @@ abstract class ModuleInstallerAPI $sRepair = "UPDATE `$sTableName` SET `$sFinalClassCol` = '$sTo' WHERE `$sFinalClassCol` = BINARY '$sFrom'"; CMDBSource::Query($sRepair); $iAffectedRows = CMDBSource::AffectedRows(); - SetupPage::log_info("Renaming class in DB - final class from '$sFrom' to '$sTo': $iAffectedRows rows affected"); + SetupLog::Info("Renaming class in DB - final class from '$sFrom' to '$sTo': $iAffectedRows rows affected"); } } catch(Exception $e) { - SetupPage::log_warning("Failed to rename class in DB - final class from '$sFrom' to '$sTo'. Reason: ".$e->getMessage()); + SetupLog::Warning("Failed to rename class in DB - final class from '$sFrom' to '$sTo'. Reason: ".$e->getMessage()); } } @@ -122,7 +122,7 @@ abstract class ModuleInstallerAPI { if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) { - SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - from '$sFrom' to '$sTo' failed. Reason '$sAttCode' is not a valid attribute of the class '$sClass'."); + SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - from '$sFrom' to '$sTo' failed. Reason '$sAttCode' is not a valid attribute of the class '$sClass'."); return; } $sOriginClass = MetaModel::GetAttributeOrigin($sClass, $sAttCode); @@ -162,7 +162,7 @@ abstract class ModuleInstallerAPI if (strtolower($sTo) == strtolower($sFrom)) { - SetupPage::log_info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo' (just a change in the case)"); + SetupLog::Info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo' (just a change in the case)"); $aTargetValues = array(); foreach ($aCurrentValues as $sValue) { @@ -180,7 +180,7 @@ abstract class ModuleInstallerAPI { // 1st - Allow both values in the column definition // - SetupPage::log_info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo'"); + SetupLog::Info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo'"); $aAllValues = $aCurrentValues; $aAllValues[] = $sTo; $sColumnDefinition = "ENUM(".implode(",", CMDBSource::Quote($aAllValues)).") $sNullSpec"; @@ -192,7 +192,7 @@ abstract class ModuleInstallerAPI $sRepair = "UPDATE `$sTableName` SET `$sEnumCol` = '$sTo' WHERE `$sEnumCol` = BINARY '$sFrom'"; CMDBSource::Query($sRepair); $iAffectedRows = CMDBSource::AffectedRows(); - SetupPage::log_info("Changing enum in DB - $iAffectedRows rows updated"); + SetupLog::Info("Changing enum in DB - $iAffectedRows rows updated"); // 3rd - Remove the useless value from the column definition // @@ -208,25 +208,25 @@ abstract class ModuleInstallerAPI $sColumnDefinition = "ENUM(".implode(",", CMDBSource::Quote($aTargetValues)).") $sNullSpec"; $sRepair = "ALTER TABLE `$sTableName` MODIFY `$sEnumCol` $sColumnDefinition"; CMDBSource::Query($sRepair); - SetupPage::log_info("Changing enum in DB - removed useless value '$sFrom'"); + SetupLog::Info("Changing enum in DB - removed useless value '$sFrom'"); } } } else { - SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sFrom' is still a valid value (".implode(', ', $aNewValues).")"); + SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sFrom' is still a valid value (".implode(', ', $aNewValues).")"); } } else { - SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' is not a known value (".implode(', ', $aNewValues).")"); + SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' is not a known value (".implode(', ', $aNewValues).")"); } } } } catch(Exception $e) { - SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' failed. Reason ".$e->getMessage()); + SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' failed. Reason ".$e->getMessage()); } } diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index a222fd98f..2fe1a5d49 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -884,19 +884,19 @@ class RunTimeEnvironment */ protected function log_error($sText) { - SetupPage::log_error($sText); + SetupLog::Error($sText); } protected function log_warning($sText) { - SetupPage::log_warning($sText); + SetupLog::Warning($sText); } protected function log_info($sText) { - SetupPage::log_info($sText); + SetupLog::Info($sText); } protected function log_ok($sText) { - SetupPage::log_ok($sText); + SetupLog::Ok($sText); } /** @@ -1088,7 +1088,7 @@ class RunTimeEnvironment isset($aAvailableModules[$sModuleId]['installer']) ) { $sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer']; - SetupPage::log_info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName(oConfig, {$aModule['version_db']}, {$aModule['version_code']})"); + SetupLog::Info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName(oConfig, {$aModule['version_db']}, {$aModule['version_code']})"); $aCallSpec = array($sModuleInstallerClass, $sHandlerName); if (is_callable($aCallSpec)) { @@ -1110,8 +1110,8 @@ class RunTimeEnvironment CMDBObject::SetTrackInfo("Initialization"); $oMyChange = CMDBObject::GetCurrentChange(); - - SetupPage::log_info("starting data load session"); + + SetupLog::Info("starting data load session"); $oDataLoader->StartSession($oMyChange); $aFiles = array(); @@ -1161,7 +1161,7 @@ class RunTimeEnvironment foreach($aPreviouslyLoadedFiles as $sFileRelativePath) { $sFileName = APPROOT.$sFileRelativePath; - SetupPage::log_info("Loading file: $sFileName (just to get the keys mapping)"); + SetupLog::Info("Loading file: $sFileName (just to get the keys mapping)"); if (empty($sFileName) || !file_exists($sFileName)) { throw(new Exception("File $sFileName does not exist")); @@ -1169,13 +1169,13 @@ class RunTimeEnvironment $oDataLoader->LoadFile($sFileName, true); $sResult = sprintf("loading of %s done.", basename($sFileName)); - SetupPage::log_info($sResult); + SetupLog::Info($sResult); } foreach($aFiles as $sFileRelativePath) { $sFileName = APPROOT.$sFileRelativePath; - SetupPage::log_info("Loading file: $sFileName"); + SetupLog::Info("Loading file: $sFileName"); if (empty($sFileName) || !file_exists($sFileName)) { throw(new Exception("File $sFileName does not exist")); @@ -1183,11 +1183,11 @@ class RunTimeEnvironment $oDataLoader->LoadFile($sFileName); $sResult = sprintf("loading of %s done.", basename($sFileName)); - SetupPage::log_info($sResult); + SetupLog::Info($sResult); } $oDataLoader->EndSession(); - SetupPage::log_info("ending data load session"); + SetupLog::Info("ending data load session"); } /** diff --git a/setup/setuppage.class.inc.php b/setup/setuppage.class.inc.php index a25ad3d23..67ab6084d 100644 --- a/setup/setuppage.class.inc.php +++ b/setup/setuppage.class.inc.php @@ -151,26 +151,27 @@ class SetupPage extends NiceWebPage return parent::output(); } + //@deprecated since 2.8.0 use SetupLog::Error public static function log_error($sText) { SetupLog::Error($sText); } - + //@deprecated since 2.8.0 use SetupLog::Warning public static function log_warning($sText) { SetupLog::Warning($sText); } - + //@deprecated since 2.8.0 use SetupLog::Info public static function log_info($sText) { SetupLog::Info($sText); } - + //@deprecated since 2.8.0 use SetupLog::Ok public static function log_ok($sText) { SetupLog::Ok($sText); } - + //@deprecated since 2.8.0 use SetupLog::Ok public static function log($sText) { SetupLog::Ok($sText); diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 917eec87b..881db8462 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -253,7 +253,7 @@ class SetupUtils } } } - SetupPage::log("Info - php.ini file(s): '$sPhpIniFile'"); + SetupLog::Ok("Info - php.ini file(s): '$sPhpIniFile'"); } if (!ini_get('file_uploads')) @@ -280,7 +280,7 @@ class SetupUtils } else { - SetupPage::log("Info - Temporary directory for files upload ($sUploadTmpDir) is writable."); + SetupLog::Ok("Info - Temporary directory for files upload ($sUploadTmpDir) is writable."); } } @@ -305,9 +305,9 @@ class SetupUtils } - SetupPage::log("Info - upload_max_filesize: ".ini_get('upload_max_filesize')); - SetupPage::log("Info - post_max_size: ".ini_get('post_max_size')); - SetupPage::log("Info - max_file_uploads: ".ini_get('max_file_uploads')); + SetupLog::Ok("Info - upload_max_filesize: ".ini_get('upload_max_filesize')); + SetupLog::Ok("Info - post_max_size: ".ini_get('post_max_size')); + SetupLog::Ok("Info - max_file_uploads: ".ini_get('max_file_uploads')); // Check some more ini settings here, needed for file upload $sMemoryLimit = trim(ini_get('memory_limit')); @@ -329,7 +329,7 @@ class SetupUtils } else { - SetupPage::log("Info - memory_limit is $iMemoryLimit, ok."); + SetupLog::Ok("Info - memory_limit is $iMemoryLimit, ok."); } } @@ -353,7 +353,7 @@ class SetupUtils } else { - SetupPage::log("Info - suhosin.get.max_value_length = $iGetMaxValueLength, ok."); + SetupLog::Ok("Info - suhosin.get.max_value_length = $iGetMaxValueLength, ok."); } } @@ -380,7 +380,7 @@ class SetupUtils if (ini_get('session.save_handler') == 'files') { $sSavePath = ini_get('session.save_path'); - SetupPage::log("Info - session.save_path is: '$sSavePath'."); + SetupLog::Ok("Info - session.save_path is: '$sSavePath'."); // According to the PHP documentation, the format can be /path/where/to_save_sessions or "N;/path/where/to_save_sessions" or "N;MODE;/path/where/to_save_sessions" $sSavePath = ltrim(rtrim($sSavePath, '"'), '"'); // remove surrounding quotes (if any) @@ -450,7 +450,7 @@ class SetupUtils */ private static function CheckPhpVersion(&$aResult) { - SetupPage::log('Info - CheckPHPVersion'); + SetupLog::Ok('Info - CheckPHPVersion'); $sPhpVersion = phpversion(); if (version_compare($sPhpVersion, self::PHP_MIN_VERSION, '>=')) @@ -497,7 +497,7 @@ class SetupUtils public static function CheckSelectedModules($sSourceDir, $sExtensionDir, $aSelectedModules) { $aResult = array(); - SetupPage::log('Info - CheckSelectedModules'); + SetupLog::Ok('Info - CheckSelectedModules'); $aDirsToScan = array(APPROOT.$sSourceDir); $sExtensionsPath = APPROOT.$sExtensionDir; @@ -528,7 +528,7 @@ class SetupUtils public static function CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir = null) { $aResult = array(); - SetupPage::log('Info - CheckBackupPrerequisites'); + SetupLog::Ok('Info - CheckBackupPrerequisites'); // zip extension // @@ -546,7 +546,7 @@ class SetupUtils // availability of exec() // $aDisabled = explode(', ', ini_get('disable_functions')); - SetupPage::log('Info - PHP functions disabled: '.implode(', ', $aDisabled)); + SetupLog::Ok('Info - PHP functions disabled: '.implode(', ', $aDisabled)); if (in_array('exec', $aDisabled)) { $aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server"); @@ -564,7 +564,7 @@ class SetupUtils } else { - SetupPage::log('Info - Found mysql_bindir: '.$sMySQLBinDir); + SetupLog::Ok('Info - Found mysql_bindir: '.$sMySQLBinDir); $sMySQLDump = '"'.$sMySQLBinDir.'/mysqldump"'; } $sCommand = "$sMySQLDump -V 2>&1"; @@ -588,7 +588,7 @@ class SetupUtils } foreach($aOutput as $sLine) { - SetupPage::log('Info - mysqldump -V said: '.$sLine); + SetupLog::Ok('Info - mysqldump -V said: '.$sLine); } // create and test destination location @@ -618,12 +618,12 @@ class SetupUtils public static function CheckGraphviz($sGraphvizPath) { $oResult = null; - SetupPage::log('Info - CheckGraphviz'); + SetupLog::Ok('Info - CheckGraphviz'); // availability of exec() // $aDisabled = explode(', ', ini_get('disable_functions')); - SetupPage::log('Info - PHP functions disabled: '.implode(', ', $aDisabled)); + SetupLog::Ok('Info - PHP functions disabled: '.implode(', ', $aDisabled)); if (in_array('exec', $aDisabled)) { $aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server"); @@ -653,7 +653,7 @@ class SetupUtils } foreach($aOutput as $sLine) { - SetupPage::log('Info - '.$sGraphvizPath.' -V said: '.$sLine); + SetupLog::Ok('Info - '.$sGraphvizPath.' -V said: '.$sLine); } return $oResult; @@ -726,11 +726,11 @@ class SetupUtils { if (!unlink($dir.'/'.$file)) { - SetupPage::log("Warning - FAILED to remove file '$dir/$file'"); + SetupLog::Ok("Warning - FAILED to remove file '$dir/$file'"); } else if (file_exists($dir.'/'.$file)) { - SetupPage::log("Warning - FAILED to remove file '$dir/.$file'"); + SetupLog::Ok("Warning - FAILED to remove file '$dir/.$file'"); } } } @@ -2115,7 +2115,7 @@ JS { if (class_exists('SetupPage')) { - SetupPage::log($sText); + SetupLog::Ok($sText); } else { diff --git a/setup/xmldataloader.class.inc.php b/setup/xmldataloader.class.inc.php index 6a9e28e01..30eaeb996 100644 --- a/setup/xmldataloader.class.inc.php +++ b/setup/xmldataloader.class.inc.php @@ -193,7 +193,7 @@ class XMLDataLoader { if (!MetaModel::IsValidClass($sClass)) { - SetupPage::log_error("Unknown class - $sClass"); + SetupLog::Error("Unknown class - $sClass"); throw(new Exception("Unknown class - $sClass")); } @@ -245,7 +245,7 @@ class XMLDataLoader else { $sMsg = "Ext key not reconcilied - $sClass/$iSrcId - $sAttCode: '".$sQuery."' - found $iMatches matche(s)"; - SetupPage::log_error($sMsg); + SetupLog::Error($sMsg); $this->m_aErrors[] = $sMsg; $iExtKey = 0; } @@ -291,7 +291,7 @@ class XMLDataLoader { // $res contains the error description $sMsg = "Value not allowed - $sClass/$iSrcId - $sAttCode: '".$oSubNode."' ; $res"; - SetupPage::log_error($sMsg); + SetupLog::Error($sMsg); $this->m_aErrors[] = $sMsg; } $oTargetObj->Set($sAttCode, $value); @@ -378,7 +378,7 @@ class XMLDataLoader } catch(Exception $e) { - SetupPage::log_error("An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage()); + SetupLog::Error("An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage()); $this->m_aErrors[] = "An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage(); } $aParentClasses = MetaModel::EnumParentClasses($sClass); @@ -417,7 +417,7 @@ class XMLDataLoader if ($iExtKey == 0) { $sMsg = "unresolved extkey in $sClass::".$oTargetObj->GetKey()."(".$oTargetObj->GetName().")::$sAttCode=$sTargetClass::$iTempKey"; - SetupPage::log_warning($sMsg); + SetupLog::Warning($sMsg); $this->m_aWarnings[] = $sMsg; //echo "aKeys[".$sTargetClass."]:\n"; //print_r($this->m_aKeys[$sTargetClass]);