Substitute array_diff function with array_udiff to allow overriding __toString()
This commit is contained in:
parent
0436fc8e96
commit
d8352d67fa
@ -577,7 +577,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
@ -605,11 +605,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
||||
}
|
||||
public function getDeleteDiff()
|
||||
{
|
||||
return array_diff($this->_snapshot, $this->data);
|
||||
return array_udiff($this->_snapshot, $this->data, array($this, "compareRecords"));
|
||||
}
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user