瀏覽代碼

Could not add more than one link between a given server and a given network device. This is a regression in 2.2.0 beta. This issue affect N-N links where duplicates are allowed. One single link is being affected in the standard datamodel.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3745 a333f486-631f-4898-b8df-5754b55c2be0
romainq 9 年之前
父節點
當前提交
8a28723b1e
共有 2 個文件被更改,包括 14 次插入3 次删除
  1. 12 2
      core/attributedef.class.inc.php
  2. 2 1
      core/dbobject.class.php

+ 12 - 2
core/attributedef.class.inc.php

@@ -1135,8 +1135,18 @@ class AttributeLinkedSet extends AttributeDefinition
 			return false;
 		}
 
-		// Both values are Object sets
-		return $val1->HasSameContents($val2);
+		// Note: maintain this algorithm so as to make sure it is strictly equivalent to the one used within DBObject::DBWriteLinks()
+		$sExtKeyToMe = $this->GetExtKeyToMe();
+		$sAdditionalKey = null;
+		if ($this->IsIndirect() && !$this->DuplicatesAllowed())
+		{
+			$sAdditionalKey = $this->GetExtKeyToRemote();
+		}
+		$oComparator = new DBObjectSetComparator($val1, $val2, array($sExtKeyToMe), $sAdditionalKey);
+		$aChanges = $oComparator->GetDifferences();
+
+		$bAreEquivalent = (count($aChanges['added']) == 0) && (count($aChanges['removed']) == 0) && (count($aChanges['modified']) == 0);
+		return $bAreEquivalent;
 	}
 
 	/**

+ 2 - 1
core/dbobject.class.php

@@ -1366,9 +1366,10 @@ abstract class DBObject implements iDisplay
 			if (!array_key_exists($sAttCode, $this->m_aTouchedAtt)) continue;
 			if (array_key_exists($sAttCode, $this->m_aModifiedAtt) && ($this->m_aModifiedAtt[$sAttCode] == false)) continue;
 				
+			// Note: any change to this algorithm must be reproduced into the implementation of AttributeLinkSet::Equals()
 			$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
 			$sAdditionalKey = null;
-			if ($oAttDef->IsIndirect())
+			if ($oAttDef->IsIndirect() && !$oAttDef->DuplicatesAllowed())
 			{
 				$sAdditionalKey = $oAttDef->GetExtKeyToRemote();
 			}