Fix at end navigation condition for query pages
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 28 Jul 2012 23:05:38 +0000 (01:05 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 28 Jul 2012 23:05:38 +0000 (01:05 +0200)
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

index 4440aac..501fd2f 100644 (file)
@@ -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( '<p>' . $paging . '</p>' );
                        } 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