diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index f1e47dd65..ef62d87b0 100644 --- a/core/attributedef.class.inc.php +++ b/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; } /** diff --git a/core/dbobject.class.php b/core/dbobject.class.php index b4889da34..24fc4bc1e 100644 --- a/core/dbobject.class.php +++ b/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(); }