From 1fd4fbf4fae3a5e9a28d68e30b48de66e18c0fa0 Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Fri, 31 Mar 2017 13:47:01 +0200 Subject: [PATCH] fixed clear all article view documents --- Document/Index/ArticleIndexer.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Document/Index/ArticleIndexer.php b/Document/Index/ArticleIndexer.php index 8330e1c92..b713f8066 100644 --- a/Document/Index/ArticleIndexer.php +++ b/Document/Index/ArticleIndexer.php @@ -293,16 +293,14 @@ public function clear() ->addQuery(new MatchAllQuery()) ->setSize($pageSize); - $count = $repository->count($repository->createSearch()->addQuery(new MatchAllQuery())); - $maxPage = ceil($count / $pageSize); - for ($page = 1; $page <= $maxPage; ++$page) { - $search->setFrom(($page - 1) * $pageSize); - foreach ($repository->execute($search) as $document) { + do { + $result = $repository->execute($search); + foreach ($result as $document) { $this->manager->remove($document); } $this->manager->commit(); - } + } while ($result->count() !== 0); $this->manager->clearCache(); $this->manager->flush();