mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 09:38:48 +02:00
Setup: Display the XML errors on the screen (cleanup deprecated functions)
SVN:trunk[5717]
This commit is contained in:
@@ -525,32 +525,17 @@ class ApplicationInstaller
|
||||
$oFactory->LoadModule($oDelta);
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$sEnvironment.'-with-delta.xml');
|
||||
}
|
||||
//$oFactory->Dump();
|
||||
if ($oFactory->HasLoadErrors())
|
||||
{
|
||||
foreach($oFactory->GetLoadErrors() as $sModuleId => $aErrors)
|
||||
{
|
||||
SetupPage::log_error("Data model source file (xml) could not be loaded - found errors in module: $sModuleId");
|
||||
foreach($aErrors as $oXmlError)
|
||||
{
|
||||
SetupPage::log_error("Load error: File: ".$oXmlError->file." Line:".$oXmlError->line." Message:".$oXmlError->message);
|
||||
}
|
||||
}
|
||||
throw new Exception("The data model could not be compiled. Please check the setup error log");
|
||||
}
|
||||
else
|
||||
{
|
||||
$oMFCompiler = new MFCompiler($oFactory);
|
||||
$oMFCompiler->Compile($sTargetPath, null, $bUseSymbolicLinks);
|
||||
//$aCompilerLog = $oMFCompiler->GetLog();
|
||||
//SetupPage::log_info(implode("\n", $aCompilerLog));
|
||||
SetupPage::log_info("Data model successfully compiled to '$sTargetPath'.");
|
||||
|
||||
$sCacheDir = APPROOT.'/data/cache-'.$sEnvironment.'/';
|
||||
SetupUtils::builddir($sCacheDir);
|
||||
SetupUtils::tidydir($sCacheDir);
|
||||
}
|
||||
|
||||
$oMFCompiler = new MFCompiler($oFactory);
|
||||
$oMFCompiler->Compile($sTargetPath, null, $bUseSymbolicLinks);
|
||||
//$aCompilerLog = $oMFCompiler->GetLog();
|
||||
//SetupPage::log_info(implode("\n", $aCompilerLog));
|
||||
SetupPage::log_info("Data model successfully compiled to '$sTargetPath'.");
|
||||
|
||||
$sCacheDir = APPROOT.'/data/cache-'.$sEnvironment.'/';
|
||||
SetupUtils::builddir($sCacheDir);
|
||||
SetupUtils::tidydir($sCacheDir);
|
||||
|
||||
// Special case to patch a ugly patch in itop-config-mgmt
|
||||
$sFileToPatch = $sTargetPath.'/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php';
|
||||
if (file_exists($sFileToPatch))
|
||||
|
||||
@@ -821,18 +821,28 @@ class ModelFactory
|
||||
|
||||
/**
|
||||
* XML load errors (XML format and validation)
|
||||
* @Deprecated Errors are now sent by Exception
|
||||
*/
|
||||
function HasLoadErrors()
|
||||
{
|
||||
return (count(self::$aLoadErrors) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated Errors are now sent by Exception
|
||||
* @return array
|
||||
*/
|
||||
function GetLoadErrors()
|
||||
{
|
||||
return self::$aLoadErrors;
|
||||
}
|
||||
|
||||
function GetXMLErrorMessage($aErrors)
|
||||
/**
|
||||
* @param array $aErrors
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function GetXMLErrorMessage($aErrors)
|
||||
{
|
||||
$sMessage = "Data model source file ({$aErrors[0]->file}) could not be loaded : \n";
|
||||
foreach($aErrors as $oXmlError)
|
||||
|
||||
@@ -526,48 +526,32 @@ class RunTimeEnvironment
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$this->sTargetEnv.'.xml');
|
||||
}
|
||||
$oFactory->LoadModule($oModule);
|
||||
if ($oFactory->HasLoadErrors())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oFactory->HasLoadErrors())
|
||||
|
||||
if ($oModule instanceof MFDeltaModule)
|
||||
{
|
||||
foreach($oFactory->GetLoadErrors() as $sModuleId => $aErrors)
|
||||
{
|
||||
echo "<h3>Module: ".$sModuleId."</h3>\n";
|
||||
foreach($aErrors as $oXmlError)
|
||||
{
|
||||
echo "<p>File: ".$oXmlError->file." Line:".$oXmlError->line." Message:".$oXmlError->message."</p>\n";
|
||||
}
|
||||
}
|
||||
// A delta was loaded, let's save a second copy of the datamodel
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$this->sTargetEnv.'-with-delta.xml');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oModule instanceof MFDeltaModule)
|
||||
{
|
||||
// A delta was loaded, let's save a second copy of the datamodel
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$this->sTargetEnv.'-with-delta.xml');
|
||||
}
|
||||
else
|
||||
{
|
||||
// No delta was loaded, let's save the datamodel now
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$this->sTargetEnv.'.xml');
|
||||
}
|
||||
|
||||
$sTargetDir = APPROOT.'env-'.$this->sTargetEnv;
|
||||
self::MakeDirSafe($sTargetDir);
|
||||
$bSkipTempDir = ($this->sFinalEnv != $this->sTargetEnv); // No need for a temporary directory if sTargetEnv is already a temporary directory
|
||||
$oMFCompiler = new MFCompiler($oFactory);
|
||||
$oMFCompiler->Compile($sTargetDir, null, $bUseSymLinks, $bSkipTempDir);
|
||||
|
||||
$sCacheDir = APPROOT.'data/cache-'.$this->sTargetEnv;
|
||||
SetupUtils::builddir($sCacheDir);
|
||||
SetupUtils::tidydir($sCacheDir);
|
||||
|
||||
MetaModel::ResetCache(md5(APPROOT).'-'.$this->sTargetEnv);
|
||||
// No delta was loaded, let's save the datamodel now
|
||||
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$this->sTargetEnv.'.xml');
|
||||
}
|
||||
|
||||
$sTargetDir = APPROOT.'env-'.$this->sTargetEnv;
|
||||
self::MakeDirSafe($sTargetDir);
|
||||
$bSkipTempDir = ($this->sFinalEnv != $this->sTargetEnv); // No need for a temporary directory if sTargetEnv is already a temporary directory
|
||||
$oMFCompiler = new MFCompiler($oFactory);
|
||||
$oMFCompiler->Compile($sTargetDir, null, $bUseSymLinks, $bSkipTempDir);
|
||||
|
||||
$sCacheDir = APPROOT.'data/cache-'.$this->sTargetEnv;
|
||||
SetupUtils::builddir($sCacheDir);
|
||||
SetupUtils::tidydir($sCacheDir);
|
||||
|
||||
MetaModel::ResetCache(md5(APPROOT).'-'.$this->sTargetEnv);
|
||||
|
||||
return array_keys($aModulesToCompile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user