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:
parent
21b65d8079
commit
1053e62e20
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue