From cced2bd6c3c57ecac8f95927635e7c5842028796 Mon Sep 17 00:00:00 2001 From: romanb Date: Tue, 15 Dec 2009 18:38:15 +0000 Subject: [PATCH] [2.0][DDC-211] Fixed collection diff calculation. --- lib/Doctrine/ORM/PersistentCollection.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 9cca5ecb6..2c5f374e8 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -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;}); } /**