diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index 810e7249d..d8263c72e 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -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)) diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index 2498e7459..76a646008 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -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) diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index 9b2c2dfb0..ae0313d30 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -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 "
File: ".$oXmlError->file." Line:".$oXmlError->line." Message:".$oXmlError->message."
\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); }