From: Chad Horohoe Date: Tue, 1 Jul 2014 19:28:53 +0000 (-0700) Subject: SpecialSearch: Fix pagination X-Git-Tag: 1.31.0-rc.0~15132^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=82afee57ef9a8ab68b56f494c174069e4af0ba29;p=lhc%2Fweb%2Fwiklou.git 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 --- 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";