Skip to content

Commit

Permalink
Merge pull request #16 from jmsche/patch-2
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 4e2c483 + 5f86f37 commit 445c363
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Listener/IndexSubscriber.php
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 445c363

Please sign in to comment.