Skip to content

Commit

Permalink
Merge pull request #15 from jmsche/patch-1
Browse files Browse the repository at this point in the history
Better check for scheduled (un)indexation
  • Loading branch information
Pierre Vanliefland committed Jun 15, 2015
2 parents bb36482 + 624a090 commit 94a05a0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Listener/IndexSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public function postFlush(PostFlushEventArgs $ea)
*/
private function scheduleForIndexation($entity)
{
if ($this->isManaged($entity) && !in_array($entity, $this->scheduledIndexations)) {
$this->scheduledIndexations[] = $entity;
$entityHash = spl_object_hash($entity);
if ($this->isManaged($entity) && !isset($this->scheduledIndexations[$entityHash])) {
$this->scheduledIndexations[$entityHash] = $entity;
}
}

Expand All @@ -119,8 +120,9 @@ private function scheduleForIndexation($entity)
*/
private function scheduleForUnindexation($entity)
{
if ($this->isManaged($entity) && !in_array($entity, $this->scheduledUnindexations)) {
$this->scheduledUnindexations[]= $entity;
$entityHash = spl_object_hash($entity);
if ($this->isManaged($entity) && !isset($this->scheduledUnindexations[$entityHash])) {
$this->scheduledUnindexations[$entityHash] = $entity;
}
}

Expand Down Expand Up @@ -149,4 +151,4 @@ private function isManaged($entity)

return $managed;
}
}
}

0 comments on commit 94a05a0

Please sign in to comment.