Commit d8352d67 authored by jackbravo's avatar jackbravo

Substitute array_diff function with array_udiff to allow overriding __toString()

parent 0436fc8e
...@@ -577,7 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator ...@@ -577,7 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/ */
public function processDiff() public function processDiff()
{ {
foreach (array_diff($this->_snapshot, $this->data) as $record) { foreach (array_udiff($this->_snapshot, $this->data, array($this, "compareRecords")) as $record) {
$record->delete(); $record->delete();
} }
...@@ -605,11 +605,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator ...@@ -605,11 +605,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
} }
public function getDeleteDiff() public function getDeleteDiff()
{ {
return array_diff($this->_snapshot, $this->data); return array_udiff($this->_snapshot, $this->data, array($this, "compareRecords"));
} }
public function getInsertDiff() public function getInsertDiff()
{ {
return array_diff($this->data, $this->_snapshot); return array_udiff($this->data, $this->_snapshot, array($this, "compareRecords"));
}
/**
* compareRecords
* Compares two records. To be used on _snapshot diffs using array_udiff
*/
protected function compareRecords($a, $b)
{
if ($a->getOid() == $b->getOid()) return 0;
return ($a->getOid() > $b->getOid()) ? 1 : -1;
} }
/** /**
* save * save
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment