Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DDC-1210 - Optimize UnitOfWork collection handling internally.

  • Loading branch information...
commit 4474d305cb89f2b12e7df2cf310065732fc8e50e 1 parent 7c244ab
@beberlei beberlei authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/Doctrine/ORM/UnitOfWork.php
View
14 lib/Doctrine/ORM/UnitOfWork.php
@@ -490,8 +490,9 @@ public function computeChangeSet(ClassMetadata $class, $entity)
}
} else if ($orgValue instanceof PersistentCollection && $orgValue !== $actualValue) {
// A PersistentCollection was de-referenced, so delete it.
- if ( ! in_array($orgValue, $this->collectionDeletions, true)) {
- $this->collectionDeletions[] = $orgValue;
+ $coid = spl_object_hash($orgValue);
+ if ( ! isset($this->collectionDeletions[$coid]) ) {
+ $this->collectionDeletions[$coid] = $orgValue;
$changeSet[$propName] = $orgValue; // Signal changeset, to-many assocs will be ignored.
}
}
@@ -569,10 +570,11 @@ public function computeChangeSets()
private function computeAssociationChanges($assoc, $value)
{
if ($value instanceof PersistentCollection && $value->isDirty()) {
+ $coid = spl_object_hash($value);
if ($assoc['isOwningSide']) {
- $this->collectionUpdates[] = $value;
+ $this->collectionUpdates[$coid] = $value;
}
- $this->visitedCollections[] = $value;
+ $this->visitedCollections[$coid] = $value;
}
// Look through the entities, and in any of their associations, for transient (new)
@@ -1889,12 +1891,12 @@ public function scheduleCollectionDeletion(PersistentCollection $coll)
{
//TODO: if $coll is already scheduled for recreation ... what to do?
// Just remove $coll from the scheduled recreations?
- $this->collectionDeletions[] = $coll;
+ $this->collectionDeletions[spl_object_hash($coll)] = $coll;
}
public function isCollectionScheduledForDeletion(PersistentCollection $coll)
{
- return in_array($coll, $this->collectionsDeletions, true);
+ return isset( $this->collectionsDeletions[spl_object_hash($coll)] );
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.