From 1053e62e20f607113807d35035b4ce1f98bc3427 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Feb 2015 13:03:46 +0100 Subject: [PATCH] doc/lib: Fix DocSearchIterator::count() counting too many Because DocSearchIterator is a recursive filter iterator and we accept any hode having children, those children not matching any of the search criteria were counted too because of iterator_count. refs #6630 --- modules/doc/library/Doc/Search/DocSearchIterator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/doc/library/Doc/Search/DocSearchIterator.php b/modules/doc/library/Doc/Search/DocSearchIterator.php index a3a4d8504..f0a9a4967 100644 --- a/modules/doc/library/Doc/Search/DocSearchIterator.php +++ b/modules/doc/library/Doc/Search/DocSearchIterator.php @@ -50,7 +50,7 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable */ public function accept() { - $section = $this->getInnerIterator()->current(); + $section = $this->current(); /** @type $section \Icinga\Module\Doc\DocSection */ $matches = array(); if (($match = $this->search->search($section->getTitle())) !== null) { @@ -97,7 +97,13 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable */ public function count() { - return iterator_count($this); + $count = 0; + foreach ($this as $section) { + if ($this->getMatches() !== null) { + ++$count; + } + } + return $count; } /**