From d8e166b1ac474d302ad5390a3e8fb8a1c2e9930f Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 29 Jul 2012 01:05:38 +0200 Subject: [PATCH] Fix at end navigation condition for query pages When looking at offet=1950 and limit=50 with a maximum of 2000 pages, the show next link should not be active. Change-Id: I0c3c2f2e46449cb6c35c227dec69363a7530b8ca --- includes/QueryPage.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 4440aac3a0..501fd2fe32 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -483,10 +483,11 @@ abstract class QueryPage extends SpecialPage { // TODO: Use doQuery() if ( !$this->isCached() ) { - $res = $this->reallyDoQuery( $this->limit, $this->offset ); + # select one extra row for navigation + $res = $this->reallyDoQuery( $this->limit + 1, $this->offset ); } else { - # Get the cached result - $res = $this->fetchFromCache( $this->limit, $this->offset ); + # Get the cached result, select one extra row for navigation + $res = $this->fetchFromCache( $this->limit + 1, $this->offset ); if ( !$this->listoutput ) { # Fetch the timestamp of this update @@ -528,7 +529,7 @@ abstract class QueryPage extends SpecialPage { $this->numRows, $this->offset + 1 )->parseAsBlock() ); # Disable the "next" link when we reach the end $paging = $this->getLanguage()->viewPrevNext( $this->getTitle( $par ), $this->offset, - $this->limit, $this->linkParameters(), ( $this->numRows < $this->limit ) ); + $this->limit, $this->linkParameters(), ( $this->numRows <= $this->limit ) ); $out->addHTML( '

' . $paging . '

' ); } else { # No results to show, so don't bother with "showing X of Y" etc. @@ -546,7 +547,7 @@ abstract class QueryPage extends SpecialPage { $this->getSkin(), $dbr, # Should use a ResultWrapper for this $res, - $this->numRows, + min( $this->numRows, $this->limit ), # do not format the one extra row, if exist $this->offset ); # Repeat the paging links at the bottom -- 2.20.1