mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
#154 Application too slow - no need to check the DB format anytime!
SVN:trunk[594]
This commit is contained in:
@@ -3089,25 +3089,15 @@ abstract class MetaModel
|
||||
}
|
||||
}
|
||||
|
||||
public static function Startup($sConfigFile, $bAllowMissingDB = false)
|
||||
public static function Startup($sConfigFile, $bModelOnly = false)
|
||||
{
|
||||
self::LoadConfig($sConfigFile);
|
||||
if (self::DBExists())
|
||||
// !!!! #@#
|
||||
//if (true)
|
||||
{
|
||||
CMDBSource::SelectDB(self::$m_sDBName);
|
||||
if ($bModelOnly) return;
|
||||
|
||||
// Some of the init could not be done earlier (requiring classes to be declared and DB to be accessible)
|
||||
self::InitPlugins();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$bAllowMissingDB)
|
||||
{
|
||||
throw new CoreException('Database not found, check your configuration file', array('config_file'=>$sConfigFile, 'db_name'=>self::$m_sDBName));
|
||||
}
|
||||
}
|
||||
CMDBSource::SelectDB(self::$m_sDBName);
|
||||
|
||||
// Some of the init could not be done earlier (requiring classes to be declared and DB to be accessible)
|
||||
self::InitPlugins();
|
||||
}
|
||||
|
||||
public static function LoadConfig($sConfigFile)
|
||||
|
||||
@@ -66,10 +66,12 @@ class SQLQuery
|
||||
|
||||
public function __construct($sTable, $sTableAlias, $aFields, $oConditionExpr, $aFullTextNeedles, $bToDelete = true, $aValues = array())
|
||||
{
|
||||
if (!CMDBSource::IsTable($sTable))
|
||||
{
|
||||
throw new CoreException("Unknown table '$sTable'");
|
||||
}
|
||||
// This check is not needed but for developping purposes
|
||||
//if (!CMDBSource::IsTable($sTable))
|
||||
//{
|
||||
// throw new CoreException("Unknown table '$sTable'");
|
||||
//}
|
||||
|
||||
// $aFields must be an array of "alias"=>"expr"
|
||||
// $oConditionExpr must be a condition tree
|
||||
// $aValues is an array of "alias"=>value
|
||||
@@ -157,10 +159,12 @@ class SQLQuery
|
||||
private function AddJoin($sJoinType, $oSQLQuery, $sLeftField, $sRightField, $sRightTableAlias = '')
|
||||
{
|
||||
assert((get_class($oSQLQuery) == __CLASS__) || is_subclass_of($oSQLQuery, __CLASS__));
|
||||
if (!CMDBSource::IsField($this->m_sTable, $sLeftField))
|
||||
{
|
||||
throw new CoreException("Unknown field '$sLeftField' in table '".$this->m_sTable);
|
||||
}
|
||||
// No need to check this here but for development purposes
|
||||
//if (!CMDBSource::IsField($this->m_sTable, $sLeftField))
|
||||
//{
|
||||
// throw new CoreException("Unknown field '$sLeftField' in table '".$this->m_sTable);
|
||||
//}
|
||||
|
||||
if (empty($sRightTableAlias))
|
||||
{
|
||||
$sRightTableAlias = $oSQLQuery->m_sTableAlias;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -433,7 +433,7 @@ if (empty($sConfigFile))
|
||||
exit;
|
||||
}
|
||||
|
||||
MetaModel::Startup($sConfigFile, true); // allow missing DB
|
||||
MetaModel::Startup($sConfigFile, true); // load data model only
|
||||
|
||||
|
||||
$sBaseArgs = "config=".urlencode($sConfigFile);
|
||||
|
||||
@@ -342,10 +342,10 @@ function CheckServerConnection(SetupWebPage $oP, $sDBServer, $sDBUser, $sDBPwd)
|
||||
* Helper function to initialize the ORM and load the data model
|
||||
* from the given file
|
||||
* @param $sConfigFileName string The name of the configuration file to load
|
||||
* @param $bAllowMissingDatabase boolean Whether or not to allow loading a data model with no corresponding DB
|
||||
* @param $bModelOnly boolean Whether or not to allow loading a data model with no corresponding DB
|
||||
* @return none
|
||||
*/
|
||||
function InitDataModel(SetupWebPage $oP, $sConfigFileName, $bAllowMissingDatabase = true)
|
||||
function InitDataModel(SetupWebPage $oP, $sConfigFileName, $bModelOnly = true)
|
||||
{
|
||||
require_once('../core/log.class.inc.php');
|
||||
require_once('../core/coreexception.class.inc.php');
|
||||
@@ -361,8 +361,9 @@ function InitDataModel(SetupWebPage $oP, $sConfigFileName, $bAllowMissingDatabas
|
||||
require_once('../core/dbobjectsearch.class.php');
|
||||
require_once('../core/dbobjectset.class.php');
|
||||
require_once('../core/userrights.class.inc.php');
|
||||
$oP->log("Info - MetaModel::Startup from file '$sConfigFileName' (AllowMissingDB = $bAllowMissingDatabase)");
|
||||
MetaModel::Startup($sConfigFileName, $bAllowMissingDatabase);
|
||||
$oP->log("Info - MetaModel::Startup from file '$sConfigFileName' (ModelOnly = $bModelOnly)");
|
||||
|
||||
MetaModel::Startup($sConfigFileName, $bModelOnly);
|
||||
}
|
||||
/**
|
||||
* Helper function to create the database structure
|
||||
@@ -410,7 +411,7 @@ function CreateDatabaseStructure(SetupWebPage $oP, Config $oConfig, $sDBName, $s
|
||||
function CreateAdminAccount(SetupWebPage $oP, Config $oConfig, $sAdminUser, $sAdminPwd, $sLanguage)
|
||||
{
|
||||
$oP->log('Info - CreateAdminAccount');
|
||||
InitDataModel($oP, TMP_CONFIG_FILE, true); // allow missing DB
|
||||
InitDataModel($oP, TMP_CONFIG_FILE, true); // load data model only
|
||||
if (UserRights::CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage))
|
||||
{
|
||||
$oP->ok("Administrator account '$sAdminUser' created.");
|
||||
@@ -943,7 +944,7 @@ function SetupFinished(SetupWebPage $oP, $aParamValues, $iCurrentStep, Config $o
|
||||
$oConfig->WriteToFile(FINAL_CONFIG_FILE);
|
||||
|
||||
// Start the application
|
||||
InitDataModel($oP, FINAL_CONFIG_FILE, false); // DO NOT allow missing DB
|
||||
InitDataModel($oP, FINAL_CONFIG_FILE, false); // Load model and startup DB
|
||||
if (UserRights::Login($sAuthUser, $sAuthPwd))
|
||||
{
|
||||
$_SESSION['auth_user'] = $sAuthUser;
|
||||
|
||||
@@ -85,7 +85,7 @@ class XMLDataLoader
|
||||
/**
|
||||
* Initializes the ORM (MetaModel)
|
||||
*/
|
||||
protected function InitDataModel($sConfigFileName, $bAllowMissingDatabase = true)
|
||||
protected function InitDataModel($sConfigFileName)
|
||||
{
|
||||
require_once('../core/log.class.inc.php');
|
||||
require_once('../core/coreexception.class.inc.php');
|
||||
@@ -101,7 +101,7 @@ class XMLDataLoader
|
||||
require_once('../core/dbobjectsearch.class.php');
|
||||
require_once('../core/dbobjectset.class.php');
|
||||
require_once('../core/userrights.class.inc.php');
|
||||
MetaModel::Startup($sConfigFileName, $bAllowMissingDatabase);
|
||||
MetaModel::Startup($sConfigFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user