mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
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()
|
public function accept()
|
||||||
{
|
{
|
||||||
$section = $this->getInnerIterator()->current();
|
$section = $this->current();
|
||||||
/** @type $section \Icinga\Module\Doc\DocSection */
|
/** @type $section \Icinga\Module\Doc\DocSection */
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if (($match = $this->search->search($section->getTitle())) !== null) {
|
if (($match = $this->search->search($section->getTitle())) !== null) {
|
||||||
@ -97,7 +97,13 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable
|
|||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return iterator_count($this);
|
$count = 0;
|
||||||
|
foreach ($this as $section) {
|
||||||
|
if ($this->getMatches() !== null) {
|
||||||
|
++$count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user