Merge "CologneBlue rewrite: kill mWatchLinkNum, watchThisPage() is only called once...
[lhc/web/wiklou.git] / includes / QueryPage.php
index 4440aac..ac559dc 100644 (file)
@@ -45,6 +45,7 @@ $wgQueryPages = array(
        array( 'MIMEsearchPage',                'MIMEsearch'                    ),
        array( 'MostcategoriesPage',            'Mostcategories'                ),
        array( 'MostimagesPage',                'Mostimages'                    ),
+       array( 'MostinterwikisPage',            'Mostinterwikis'                ),
        array( 'MostlinkedCategoriesPage',      'Mostlinkedcategories'          ),
        array( 'MostlinkedtemplatesPage',       'Mostlinkedtemplates'           ),
        array( 'MostlinkedPage',                'Mostlinked'                    ),
@@ -432,9 +433,9 @@ abstract class QueryPage extends SpecialPage {
                        $options['ORDER BY'] = 'qc_value ASC';
                }
                $res = $dbr->select( 'querycache', array( 'qc_type',
-                               'qc_namespace AS namespace',
-                               'qc_title AS title',
-                               'qc_value AS value' ),
+                               'namespace' => 'qc_namespace',
+                               'title' => 'qc_title',
+                               'value' => 'qc_value' ),
                                array( 'qc_type' => $this->getName() ),
                                __METHOD__, $options
                );
@@ -483,10 +484,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
@@ -525,10 +527,11 @@ abstract class QueryPage extends SpecialPage {
                        $out->addHTML( $this->getPageHeader() );
                        if ( $this->numRows > 0 ) {
                                $out->addHTML( $this->msg( 'showingresults' )->numParams(
-                                       $this->numRows, $this->offset + 1 )->parseAsBlock() );
+                                       min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
+                                       $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 +549,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
@@ -556,7 +559,7 @@ abstract class QueryPage extends SpecialPage {
 
                $out->addHTML( Xml::closeElement( 'div' ) );
 
-               return $this->numRows;
+               return min( $this->numRows, $this->limit ); # do not return the one extra row, if exist
        }
 
        /**