r44648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44647‎ | r44648 | r44649 >
Date:04:25, 16 December 2008
Author:vyznev
Status:ok
Tags:
Comment:
(bug 16632) Make updateArticleCount.inc.php use COUNT instead of numRows(), as suggested by Sean Colombo.
Modified paths:
  • /trunk/phase3/maintenance/FiveUpgrade.inc (modified) (history)
  • /trunk/phase3/maintenance/updateArticleCount.inc.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/FiveUpgrade.inc
@@ -100,7 +100,7 @@
101101 $timeout = 3600 * 24;
102102 $db =& $this->newConnection();
103103 $db->bufferResults( false );
104 - if ($wgDBtype == 'mysql') {
 104+ if ($wgDBtype == 'mysql') {
105105 $db->query( "SET net_read_timeout=$timeout" );
106106 $db->query( "SET net_write_timeout=$timeout" );
107107 }
Index: trunk/phase3/maintenance/updateArticleCount.inc.php
@@ -38,7 +38,8 @@
3939 function makeSql() {
4040 list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' );
4141 $nsset = $this->makeNsSet();
42 - return "SELECT DISTINCT page_namespace,page_title FROM $page,$pagelinks " .
 42+ return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " .
 43+ "FROM $page, $pagelinks " .
4344 "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
4445 "AND page_is_redirect = 0 AND page_len > 0";
4546 }
@@ -50,15 +51,9 @@
5152 */
5253 function count() {
5354 $res = $this->dbr->query( $this->makeSql(), __METHOD__ );
54 - if( $res ) {
55 - $count = $this->dbr->numRows( $res );
56 - $this->dbr->freeResult( $res );
57 - return $count;
58 - } else {
59 - # Look out for this when handling the result
60 - # - Actually it's unreachable, !$res throws an exception -- TS
61 - return false;
62 - }
 55+ $row = $this->dbr->fetchObject( $res );
 56+ $this->dbr->freeResult( $res );
 57+ return $row->pagecount;
6358 }
6459
6560 }

Status & tagging log