$profile = new ProfileSection( __METHOD__ );
$search = $this->getSearchEngine();
- $search->setLimitOffset( $this->limit, $this->offset );
+ // Request an extra result to determine whether a "next page" link is useful
+ $search->setLimitOffset( $this->limit + 1, $this->offset );
$search->setNamespaces( $this->namespaces );
$this->saveNamespaces();
$search->prefix = $this->mPrefix;
$this->offset,
$this->limit,
$this->powerSearchOptions() + array( 'search' => $term ),
- max( $titleMatchesNum, $textMatchesNum ) < $this->limit
+ max( $titleMatchesNum, $textMatchesNum ) <= $this->limit
);
}
wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
$out = "<ul class='mw-search-results'>\n";
$result = $matches->next();
- while ( $result ) {
+ $count = 0;
+ while ( $result && $count < $this->limit ) {
$out .= $this->showHit( $result, $terms );
$result = $matches->next();
+ $count++;
}
$out .= "</ul>\n";