* Handle fallbacks too in extension aliases
[lhc/web/wiklou.git] / maintenance / updateArticleCount.inc.php
index 20546a7..de19191 100644 (file)
@@ -1,10 +1,9 @@
 <?php
-
 /**
  * Support class for the updateArticleCount.php maintenance script
  *
- * @package MediaWiki
- * @subpackage Maintenance
+ * @file
+ * @ingroup Maintenance
  * @author Rob Church <robchur@gmail.com>
  */
 
@@ -16,7 +15,7 @@ class ArticleCounter {
        function ArticleCounter() {
                global $wgContentNamespaces;
                $this->namespaces = $wgContentNamespaces;
-               $this->dbr =& wfGetDB( DB_SLAVE );
+               $this->dbr = wfGetDB( DB_SLAVE );
        }
        
        /**
@@ -37,14 +36,11 @@ class ArticleCounter {
         * @return string
         */
        function makeSql() {
-               extract( $this->dbr->tableNames( 'page', 'pagelinks' ) );
+               list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' );
                $nsset = $this->makeNsSet();
-               return "SELECT COUNT(*) AS count FROM {$page}
-                               LEFT JOIN {$pagelinks} ON pl_from = page_id
-                               WHERE page_namespace IN ( $nsset )
-                               AND page_is_redirect = 0
-                               AND page_len > 0
-                               AND pl_namespace IS NOT NULL";
+               return "SELECT DISTINCT page_namespace,page_title FROM $page,$pagelinks " .
+                       "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
+                       "AND page_is_redirect = 0 AND page_len > 0";
        }
        
        /**
@@ -55,14 +51,16 @@ class ArticleCounter {
        function count() {
                $res = $this->dbr->query( $this->makeSql(), __METHOD__ );
                if( $res ) {
-                       $row = $this->dbr->fetchObject( $res );
+                       $count = $this->dbr->numRows( $res );
                        $this->dbr->freeResult( $res );
-                       return (int)$row->count;
+                       return $count;
                } else {
-                       return false; # Look out for this when handling the result
+                       # Look out for this when handling the result
+                       #    - Actually it's unreachable, !$res throws an exception -- TS
+                       return false; 
                }
        }
 
 }
 
-?>
\ No newline at end of file
+