Explorar o código

N°1073 Reentrance issue on cmdbAbstractObject when coming from an extension implementing iApplicationObjectExtension.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4942 a333f486-631f-4898-b8df-5754b55c2be0
glajarige %!s(int64=7) %!d(string=hai) anos
pai
achega
a36cba48bb
Modificáronse 1 ficheiros con 27 adicións e 7 borrados
  1. 27 7
      application/cmdbabstract.class.inc.php

+ 27 - 7
application/cmdbabstract.class.inc.php

@@ -3536,14 +3536,34 @@ EOF
 
 
 	public function DBUpdate()
 	public function DBUpdate()
 	{
 	{
-		$res = parent::DBUpdate();
+        $res = parent::DBUpdate();
 
 
-		// Invoke extensions after the update (could be before)
-		foreach (MetaModel::EnumPlugins('iApplicationObjectExtension') as $oExtensionInstance)
-		{
-			$oExtensionInstance->OnDBUpdate($this, self::GetCurrentChange());
-		}
-		return $res;
+        // Protection against reentrance (e.g. cascading the update of ticket logs)
+        // Note: This is based on the fix made on r 3190 in DBObject::DBUpdate()
+        static $aUpdateReentrance = array();
+        $sKey = get_class($this).'::'.$this->GetKey();
+        if(array_key_exists($sKey, $aUpdateReentrance))
+        {
+            return $res;
+        }
+        $aUpdateReentrance[$sKey] = true;
+
+        try
+        {
+            // Invoke extensions after the update (could be before)
+            foreach (MetaModel::EnumPlugins('iApplicationObjectExtension') as $oExtensionInstance)
+            {
+                $oExtensionInstance->OnDBUpdate($this, self::GetCurrentChange());
+            }
+        }
+        catch(Exception $e)
+        {
+            unset($aUpdateReentrance[$sKey]);
+            throw $e;
+        }
+
+        unset($aUpdateReentrance[$sKey]);
+        return $res;
 	}
 	}
 
 
 	protected static function BulkUpdateTracked_Internal(DBSearch $oFilter, array $aValues)
 	protected static function BulkUpdateTracked_Internal(DBSearch $oFilter, array $aValues)