Browse Source

Fixed issues when adding/removing modules during the setup:
- When adding modules: the data model was not refreshed in the cache before attempting to load "structure" (or "sample") data
- When removing a module: remaining (invalid) triggers were still used.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1401 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 14 năm trước cách đây
mục cha
commit
494a4f36f8
3 tập tin đã thay đổi với 7 bổ sung36 xóa
  1. 3 5
      core/dbobject.class.php
  2. 2 1
      setup/ajax.dataloader.php
  3. 2 30
      setup/xmldataloader.class.inc.php

+ 3 - 5
core/dbobject.class.php

@@ -1203,13 +1203,11 @@ abstract class DBObject
 
 		// Activate any existing trigger 
 		$sClass = get_class($this);
-		$oSet = new DBObjectSet(new DBObjectSearch('TriggerOnObjectCreate'));
+		$sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
+		$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectCreate AS t WHERE t.target_class IN ('$sClassList')"));
 		while ($oTrigger = $oSet->Fetch())
 		{
-			if (MetaModel::IsParentClass($oTrigger->Get('target_class'), $sClass))
-			{
-				$oTrigger->DoActivate($this->ToArgs('this'));
-			}
+			$oTrigger->DoActivate($this->ToArgs('this'));
 		}
 
 		return $this->m_iKey;

+ 2 - 1
setup/ajax.dataloader.php

@@ -210,7 +210,8 @@ try
 			throw(new Exception("File $sFileName does not exist"));
 		}
 		
-		$oDataLoader = new XMLDataLoader(TMP_CONFIG_FILE); // When called by the wizard, the final config is not yet there
+		InitDataModel(TMP_CONFIG_FILE, false);  // When called by the wizard, the final config is not yet there
+		$oDataLoader = new XMLDataLoader(); 
 		if ($sSessionStatus == 'start')
 		{
 			$oChange = MetaModel::NewObject("CMDBChange");

+ 2 - 30
setup/xmldataloader.class.inc.php

@@ -46,16 +46,12 @@ class XMLDataLoader
 	protected $m_aWarnings;
 	protected $m_iCountCreated;
 
-	public function __construct($sConfigFileName = null)
+	public function __construct()
 	{
 		$this->m_aKeys = array();
 		$this->m_aObjectsCache = array();
 		$this->m_oChange = null;
 		$this->m_sCacheFileName = KEYS_CACHE_FILE;
-		if ($sConfigFileName != null)
-		{
-			$this->InitDataModel($sConfigFileName);
-		}
 		$this->LoadKeysCache();
 		$this->m_bSessionActive = true;
 		$this->m_aErrors = array();
@@ -118,31 +114,7 @@ class XMLDataLoader
 			$this->ClearKeysCache();
 		}
 	}
-	
-	/**
-	 * Initializes the ORM (MetaModel)
-	 */	 	
-	protected function InitDataModel($sConfigFileName)
-	{
-		require_once(APPROOT.'/core/log.class.inc.php');
-		require_once(APPROOT.'/core/kpi.class.inc.php');
-		require_once(APPROOT.'/core/coreexception.class.inc.php');
-		require_once(APPROOT.'/core/dict.class.inc.php');
-		require_once(APPROOT.'/core/attributedef.class.inc.php');
-		require_once(APPROOT.'/core/filterdef.class.inc.php');
-		require_once(APPROOT.'/core/stimulus.class.inc.php');
-		require_once(APPROOT.'/core/MyHelpers.class.inc.php');
-		require_once(APPROOT.'/core/expression.class.inc.php');
-		require_once(APPROOT.'/core/cmdbsource.class.inc.php');
-		require_once(APPROOT.'/core/sqlquery.class.inc.php');
-		require_once(APPROOT.'/core/dbobject.class.php');
-		require_once(APPROOT.'/core/dbobjectsearch.class.php');
-		require_once(APPROOT.'/core/dbobjectset.class.php');
-		require_once(APPROOT.'/application/cmdbabstract.class.inc.php');
-		require_once(APPROOT.'/core/userrights.class.inc.php');
-		MetaModel::Startup($sConfigFileName);
-	}
-	
+			
 	/**
 	 * Stores the keys & object cache in a file
 	 */