浏览代码

Fixed bug in change tracking: it was impossible to factorize code creating objects in the background either in the context of an object update or in the context of the application of a stimulus

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1673 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 年之前
父节点
当前提交
edc5720b46
共有 1 个文件被更改,包括 14 次插入7 次删除
  1. 14 7
      core/cmdbobject.class.inc.php

+ 14 - 7
core/cmdbobject.class.inc.php

@@ -280,9 +280,10 @@ abstract class CMDBObject extends DBObject
 	{
 		$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
 
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$ret = $this->DBInsertTracked_Internal();
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 		return $ret;
 	}
 
@@ -290,9 +291,10 @@ abstract class CMDBObject extends DBObject
 	{
 		$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
 
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$ret = $this->DBInsertTracked_Internal(true);
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 		return $ret;
 	}
 
@@ -321,9 +323,10 @@ abstract class CMDBObject extends DBObject
 
 	public function DBCloneTracked(CMDBChange $oChange, $newKey = null)
 	{
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$this->DBCloneTracked_Internal($newKey);
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 	}
 
 	protected function DBCloneTracked_Internal($newKey = null)
@@ -348,9 +351,10 @@ abstract class CMDBObject extends DBObject
 	{
 		$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
 
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$this->DBUpdateTracked_Internal();
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 	}
 
 	protected function DBUpdateTracked_Internal()
@@ -383,9 +387,10 @@ abstract class CMDBObject extends DBObject
 	{
 		$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_DELETE);
 
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$this->DBDeleteTracked_Internal($oDeletionPlan);
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 	}
 
 	protected function DBDeleteTracked_Internal(&$oDeletionPlan = null)
@@ -407,9 +412,10 @@ abstract class CMDBObject extends DBObject
 
 	public static function BulkDeleteTracked(CMDBChange $oChange, DBObjectSearch $oFilter)
 	{
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$this->BulkDeleteTracked_Internal($oFilter);
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 	}
 
 	protected static function BulkDeleteTracked_Internal(DBObjectSearch $oFilter)
@@ -446,9 +452,10 @@ abstract class CMDBObject extends DBObject
 
 	public static function BulkUpdateTracked(CMDBChange $oChange, DBObjectSearch $oFilter, array $aValues)
 	{
+		$oPreviousChange = self::$m_oCurrChange;
 		self::$m_oCurrChange = $oChange;
 		$this->BulkUpdateTracked_Internal($oFilter, $aValues);
-		self::$m_oCurrChange = null;
+		self::$m_oCurrChange = $oPreviousChange;
 	}
 
 	protected static function BulkUpdateTracked_Internal(DBObjectSearch $oFilter, array $aValues)