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
This commit is contained in:
Eric Lippmann 2015-02-11 13:03:46 +01:00
parent 21b65d8079
commit 1053e62e20
1 changed files with 8 additions and 2 deletions

View File

@ -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;
}
/**