From 82afee57ef9a8ab68b56f494c174069e4af0ba29 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 1 Jul 2014 12:28:53 -0700 Subject: [PATCH] SpecialSearch: Fix pagination This basically reverts f4357b6 but fixes it while we're here. Requesting one extra result causes extra load and weird queries against the search backend...all to be thrown away. Plus it's showing "Results 1-21 of N" when we're only showing 20 which is a regression. All search backends implement getTotalHits() so use that count instead to figure out if we're on the last page. Change-Id: Ib38b1e124bea7133f48209ef8af1b1e26b4dba75 --- includes/specials/SpecialSearch.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 13591aa695..f119288f34 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -207,8 +207,7 @@ class SpecialSearch extends SpecialPage { $profile = new ProfileSection( __METHOD__ ); $search = $this->getSearchEngine(); - // Request an extra result to determine whether a "next page" link is useful - $search->setLimitOffset( $this->limit + 1, $this->offset ); + $search->setLimitOffset( $this->limit, $this->offset ); $search->setNamespaces( $this->namespaces ); $this->saveNamespaces(); $search->prefix = $this->mPrefix; @@ -352,7 +351,7 @@ class SpecialSearch extends SpecialPage { $this->offset, $this->limit, $this->powerSearchOptions() + array( 'search' => $term ), - max( $titleMatchesNum, $textMatchesNum ) <= $this->limit + $this->limit + $this->offset >= $totalRes ); } wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) ); @@ -551,11 +550,9 @@ class SpecialSearch extends SpecialPage { $out = "\n"; -- 2.20.1