mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°1082 Fixed a regression introduced with ormLinkSet rework: Modified links not updated.
SVN:trunk[4950]
This commit is contained in:
@@ -156,9 +156,14 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
public function ModifyItem(DBObject $oLink)
|
public function ModifyItem(DBObject $oLink)
|
||||||
{
|
{
|
||||||
assert($oLink instanceof $this->sClass);
|
assert($oLink instanceof $this->sClass);
|
||||||
|
|
||||||
$iObjectId = $oLink->GetKey();
|
$iObjectId = $oLink->GetKey();
|
||||||
$this->aModified[$iObjectId] = $oLink;
|
if (array_key_exists($iObjectId, $this->aPreserved))
|
||||||
$this->bHasDelta = true;
|
{
|
||||||
|
unset($this->aPreserved[$iObjectId]);
|
||||||
|
$this->aModified[$iObjectId] = $oLink;
|
||||||
|
$this->bHasDelta = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function LoadOriginalIds()
|
protected function LoadOriginalIds()
|
||||||
@@ -169,13 +174,20 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
{
|
{
|
||||||
$this->aOriginalObjects = $this->oOriginalSet->ToArray();
|
$this->aOriginalObjects = $this->oOriginalSet->ToArray();
|
||||||
$this->aPreserved = $this->aOriginalObjects; // Copy (not effective until aPreserved gets modified)
|
$this->aPreserved = $this->aOriginalObjects; // Copy (not effective until aPreserved gets modified)
|
||||||
foreach ($this->aRemoved as $iObjectId)
|
foreach ($this->aRemoved as $iObjectId)
|
||||||
{
|
{
|
||||||
if (array_key_exists($iObjectId, $this->aPreserved))
|
if (array_key_exists($iObjectId, $this->aPreserved))
|
||||||
{
|
{
|
||||||
unset($this->aPreserved[$iObjectId]);
|
unset($this->aPreserved[$iObjectId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($this->aModified as $iObjectId)
|
||||||
|
{
|
||||||
|
if (array_key_exists($iObjectId, $this->aPreserved))
|
||||||
|
{
|
||||||
|
unset($this->aPreserved[$iObjectId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -249,7 +261,7 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
public function Count()
|
public function Count()
|
||||||
{
|
{
|
||||||
$this->LoadOriginalIds();
|
$this->LoadOriginalIds();
|
||||||
$iRet = count($this->aPreserved) + count($this->aAdded);
|
$iRet = count($this->aPreserved) + count($this->aAdded) + count($this->aModified);
|
||||||
return $iRet;
|
return $iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +322,15 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$oRet = current($this->aAdded);
|
$iModifiedCount = count($this->aModified);
|
||||||
|
if($this->iCursor < $iPreservedCount + $iModifiedCount)
|
||||||
|
{
|
||||||
|
$oRet = current($this->aModified);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$oRet = current($this->aAdded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $oRet;
|
return $oRet;
|
||||||
}
|
}
|
||||||
@@ -331,9 +351,17 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
next($this->aAdded);
|
$iModifiedCount = count($this->aModified);
|
||||||
|
if($this->iCursor < $iPreservedCount + $iModifiedCount)
|
||||||
|
{
|
||||||
|
next($this->aModified);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
next($this->aAdded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Increment AFTER moving the internal cursors because when starting aAdded, we must leave it intact
|
// Increment AFTER moving the internal cursors because when starting aModified / aAdded, we must leave it intact
|
||||||
$this->iCursor++;
|
$this->iCursor++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +401,8 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
|||||||
|
|
||||||
$this->iCursor = 0;
|
$this->iCursor = 0;
|
||||||
reset($this->aPreserved);
|
reset($this->aPreserved);
|
||||||
reset($this->aAdded);
|
reset($this->aAdded);
|
||||||
|
reset($this->aModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HasDelta()
|
public function HasDelta()
|
||||||
|
|||||||
Reference in New Issue
Block a user