1
0
mirror of synced 2025-02-20 22:23:14 +03:00

[2.0][DDC-211] Fixed collection diff calculation.

This commit is contained in:
romanb 2009-12-15 18:38:15 +00:00
parent e6a10d36d9
commit cced2bd6c3

View File

@ -275,7 +275,8 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
*/
public function getDeleteDiff()
{
return array_udiff($this->_snapshot, $this->_coll->toArray(), array($this, '_compareRecords'));
return array_udiff_assoc($this->_snapshot, $this->_coll->toArray(),
function($a, $b) {return $a === $b ? 0 : 1;});
}
/**
@ -286,17 +287,8 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
*/
public function getInsertDiff()
{
return array_udiff($this->_coll->toArray(), $this->_snapshot, array($this, '_compareRecords'));
}
/**
* Compares two records. To be used on _snapshot diffs using array_udiff.
*
* @return integer
*/
private function _compareRecords($a, $b)
{
return $a === $b ? 0 : 1;
return array_udiff_assoc($this->_coll->toArray(), $this->_snapshot,
function($a, $b) {return $a === $b ? 0 : 1;});
}
/**