r78698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78697‎ | r78698 | r78699 >
Date:17:41, 21 December 2010
Author:catrope
Status:ok
Tags:
Comment:
Store the number of result rows in $this->numRows
Modified paths:
  • /branches/querypage-work2/phase3/includes/QueryPage.php (modified) (history)

Diff [purge]

Index: branches/querypage-work2/phase3/includes/QueryPage.php
@@ -77,6 +77,13 @@
7878 */
7979 var $offset = 0;
8080 var $limit = 0;
 81+
 82+ /**
 83+ * The number of rows returned by the query. Reading this variable
 84+ * only makes sense in functions that are run after the query has been
 85+ * done, such as preprocessResults() and formatRow().
 86+ */
 87+ protected $numRows;
8188
8289 /**
8390 * Wheter to show prev/next links
@@ -443,7 +450,7 @@
444451
445452 }
446453
447 - $num = $dbr->numRows($res);
 454+ $this->numRows = $dbr->numRows( $res );
448455
449456 $this->preprocessResults( $dbr, $res );
450457
@@ -452,12 +459,12 @@
453460 # Top header and navigation
454461 if( $this->shownavigation ) {
455462 $wgOut->addHTML( $this->getPageHeader() );
456 - if( $num > 0 ) {
457 - $wgOut->addHTML( '<p>' . wfShowingResults( $this->offset, $num ) . '</p>' );
 463+ if( $this->numRows > 0 ) {
 464+ $wgOut->addHTML( '<p>' . wfShowingResults( $this->offset, $this->numRows ) . '</p>' );
458465 # Disable the "next" link when we reach the end
459466 $paging = wfViewPrevNext( $this->offset, $this->limit,
460467 $this->getTitle( $par ),
461 - wfArrayToCGI( $this->linkParameters() ), ( $num < $this->limit ) );
 468+ wfArrayToCGI( $this->linkParameters() ), ( $this->numRows < $this->limit ) );
462469 $wgOut->addHTML( '<p>' . $paging . '</p>' );
463470 } else {
464471 # No results to show, so don't bother with "showing X of Y" etc.
@@ -475,7 +482,7 @@
476483 $wgUser->getSkin(),
477484 $dbr, # Should use a ResultWrapper for this
478485 $res,
479 - $dbr->numRows( $res ),
 486+ $this->numRows,
480487 $this->offset );
481488
482489 # Repeat the paging links at the bottom
@@ -485,7 +492,7 @@
486493
487494 $wgOut->addHTML( Xml::closeElement( 'div' ) );
488495
489 - return $num;
 496+ return $this->numRows;
490497 }
491498
492499 /**

Status & tagging log