Browse Source

#972 Incomprehensible error message during setup, with a sample extension provided by Combodo! (empty user rights tag) -This fix improves a lot, but the final fix should be to compile user rights in a separate directory. To be further discussed.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3374 a333f486-631f-4898-b8df-5754b55c2be0
romainq 10 years ago
parent
commit
52aa551d43
2 changed files with 25 additions and 4 deletions
  1. 9 1
      core/metamodel.class.php
  2. 16 3
      setup/compiler.class.inc.php

+ 9 - 1
core/metamodel.class.php

@@ -4922,7 +4922,15 @@ abstract class MetaModel
 		if (!file_exists($sFile))
 		if (!file_exists($sFile))
 		{
 		{
 			$sConfigFile = self::$m_oConfig->GetLoadedFile();
 			$sConfigFile = self::$m_oConfig->GetLoadedFile();
-			throw new CoreException('Wrong filename in configuration file', array('file' => $sConfigFile, 'module' => $sModuleType, 'filename' => $sFile));
+			if (strlen($sConfigFile) > 0)
+			{
+				throw new CoreException('Include: wrong file name in configuration file', array('config file' => $sConfigFile, 'section' => $sModuleType, 'filename' => $sFile));
+			}
+			else
+			{
+				// The configuration is in memory only
+				throw new CoreException('Include: wrong file name in configuration file (in memory)', array('section' => $sModuleType, 'filename' => $sFile));
+			}
 		}
 		}
 
 
 		// Note: We do not expect the modules to output characters while loading them.
 		// Note: We do not expect the modules to output characters while loading them.

+ 16 - 3
setup/compiler.class.inc.php

@@ -116,14 +116,27 @@ class MFCompiler
 		}
 		}
 
 
 		// Determine the target module (exactly one!) for USER RIGHTS
 		// Determine the target module (exactly one!) for USER RIGHTS
-		//
+		// This used to be based solely on the module which created the user_rights node first
+		// Unfortunately, our sample extension was delivered with the xml structure, resulting in the new module to be the recipient of the compilation
+		// Then model.itop-profiles-itil would not exist... resulting in an error after the compilation (and the actual product of the compiler would never be included
+		// The bullet proof implementation would be to compile in a separate directory as it has been done with the dictionaries... that's another story
+		$aModules = $this->oFactory->GetLoadedModules();
 		$sUserRightsModule = '';
 		$sUserRightsModule = '';
+		foreach($aModules as $foo => $oModule)
+		{
+			if ($oModule->GetName() == 'itop-profiles-itil')
+			{
+				$sUserRightsModule = 'itop-profiles-itil';
+				break;
+			}
+		}
 		$oUserRightsNode = $this->oFactory->GetNodes('user_rights')->item(0);
 		$oUserRightsNode = $this->oFactory->GetNodes('user_rights')->item(0);
-		if ($oUserRightsNode)
+		if ($oUserRightsNode && ($sUserRightsModule == ''))
 		{
 		{
+			// Legacy algorithm (itop <= 2.0.3)
 			$sUserRightsModule = $oUserRightsNode->getAttribute('_created_in');
 			$sUserRightsModule = $oUserRightsNode->getAttribute('_created_in');
-			$this->Log("User Rights module found: $sUserRightsModule");
 		}
 		}
+		$this->Log("User Rights module found: '$sUserRightsModule'");
 
 
 		// List root classes
 		// List root classes
 		//
 		//