From 449c33aea3fbb50966157c442908646a69d17051 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Sat, 12 Apr 2014 13:30:52 +0200 Subject: [PATCH] Fixes multiple updates on multiple flush executions --- Doctrine/Listener.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doctrine/Listener.php b/Doctrine/Listener.php index 763ddec..ff9fc60 100644 --- a/Doctrine/Listener.php +++ b/Doctrine/Listener.php @@ -258,17 +258,21 @@ class Listener implements EventSubscriber /** * Persist scheduled objects to ElasticSearch + * After persisting, clear the scheduled queue to prevent multiple data updates when using multiple flush calls */ private function persistScheduled() { if (count($this->scheduledForInsertion)) { $this->objectPersister->insertMany($this->scheduledForInsertion); + $this->scheduledForInsertion = array(); } if (count($this->scheduledForUpdate)) { $this->objectPersister->replaceMany($this->scheduledForUpdate); + $this->scheduledForUpdate = array(); } if (count($this->scheduledForDeletion)) { $this->objectPersister->deleteManyByIdentifiers($this->scheduledForDeletion); + $this->scheduledForDeletion = array(); } }