From: umherirrender Date: Sat, 28 Jul 2012 23:05:38 +0000 (+0200) Subject: Fix at end navigation condition for query pages X-Git-Tag: 1.31.0-rc.0~22909^2 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=d8e166b1ac474d302ad5390a3e8fb8a1c2e9930f;p=lhc%2Fweb%2Fwiklou.git 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 --- 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