Explorar o código

#1111 Could not attach a UserRequest to a Problem (1-N links). Could not detach either! This fix requires attention: it is assumed that an item of a link set, if it is "modified" then its key to the current object has already been set.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3693 a333f486-631f-4898-b8df-5754b55c2be0
romainq %!s(int64=9) %!d(string=hai) anos
pai
achega
2428e8c26a
Modificáronse 3 ficheiros con 4 adicións e 15 borrados
  1. 1 1
      core/attributedef.class.inc.php
  2. 2 13
      core/dbobject.class.php
  3. 1 1
      core/dbobjectset.class.php

+ 1 - 1
core/attributedef.class.inc.php

@@ -1135,7 +1135,7 @@ class AttributeLinkedSet extends AttributeDefinition
 		}
 
 		// Both values are Object sets
-		return $val1->HasSameContents($val2, array($this->GetExtKeyToMe()));
+		return $val1->HasSameContents($val2);
 	}
 
 	/**

+ 2 - 13
core/dbobject.class.php

@@ -1384,24 +1384,13 @@ abstract class DBObject implements iDisplay
 			
 			foreach($aChanges['modified'] as $oLink)
 			{
-				// Make sure that the objects in the set point to "this"
-				$oLink->Set($oAttDef->GetExtKeyToMe(), $this->m_iKey);
+				// Objects in the set either remain attached or have been detached -> leave the link as is
 				$oLink->DBWrite();
 			}
 			
 			foreach($aChanges['removed'] as $oLink)
 			{
-				// Objects can be removed from the set because:
-				// 1) They should no longer exist
-				// 2) They are about to be removed from the set BUT NOT deleted, their ExtKey has been reset
-				if ($oLink->IsModified() && ($oLink->Get($sExtKeyToMe) != $this->m_iKey))
-				{
-					$oLink->DBWrite();
-				}
-				else
-				{
-					$oLink->DBDelete();
-				}
+				$oLink->DBDelete();
 			}
 		}
 	}

+ 1 - 1
core/dbobjectset.class.php

@@ -1318,7 +1318,7 @@ class DBObjectSetComparator
 				// Already marked as modified above
 				//$aResult['modified'][$oObj->GetKey()] = $oObj;
 			}
-			else if (!array_key_exists($sFingerprint, $this->aFingerprints1) && $oObj->IsNew())
+			else if (!array_key_exists($sFingerprint, $this->aFingerprints1))
 			{
 				$aResult['added'][] = $oObj;
 			}