From fe41d312ca77c1b17aac8902d16ae42c8aa57cc5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 31 Jul 2015 13:12:41 +0200 Subject: [PATCH] RepositoryQuery: Do not bypass the query's own iterator refs #9661 --- library/Icinga/Repository/RepositoryQuery.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Repository/RepositoryQuery.php b/library/Icinga/Repository/RepositoryQuery.php index 8b5727164..aca7c1776 100644 --- a/library/Icinga/Repository/RepositoryQuery.php +++ b/library/Icinga/Repository/RepositoryQuery.php @@ -5,6 +5,7 @@ namespace Icinga\Repository; use Iterator; use IteratorAggregate; +use Traversable; use Icinga\Application\Benchmark; use Icinga\Application\Logger; use Icinga\Data\QueryInterface; @@ -581,7 +582,12 @@ class RepositoryQuery implements QueryInterface, SortRules, Iterator $this->order(); } - $iterator = $this->repository->getDataSource()->query($this->query); + if ($this->query instanceof Traversable) { + $iterator = $this->query; + } else { + $iterator = $this->repository->getDataSource()->query($this->query); + } + if ($iterator instanceof IteratorAggregate) { $this->iterator = $iterator->getIterator(); } else {