Follow-up r62648: Add new message key to maintenance script
[lhc/web/wiklou.git] / maintenance / updateArticleCount.php
index 3b348b5..e681845 100644 (file)
@@ -22,7 +22,7 @@
  * @author Rob Church <robchur@gmail.com>
  */
 
-require_once( "Maintenance.php" );
+require_once( dirname(__FILE__) . '/Maintenance.php' );
 
 class UpdateArticleCount extends Maintenance {
 
@@ -43,7 +43,7 @@ class UpdateArticleCount extends Maintenance {
        
                if( $result !== false ) {
                        $this->output( "found {$result}.\n" );
-                       if( isset( $options['update'] ) && $options['update'] ) {
+                       if( $this->hasOption( 'update' ) ) {
                                $this->output( "Updating site statistics table... " );
                                $dbw = wfGetDB( DB_MASTER );
                                $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ );
@@ -77,7 +77,7 @@ class UpdateArticleCount extends Maintenance {
        private function makeSql( $dbr ) {
                list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
                $nsset = $this->makeNsSet();
-               return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " .
+               return "SELECT COUNT(DISTINCT page_id) AS pagecount " .
                        "FROM $page, $pagelinks " .
                        "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
                        "AND page_is_redirect = 0 AND page_len > 0";
@@ -93,7 +93,7 @@ class UpdateArticleCount extends Maintenance {
                $res = $dbr->query( $this->makeSql( $dbr ), __METHOD__ );
                $row = $dbr->fetchObject( $res );
                $dbr->freeResult( $res );
-               return $row->pagecount;
+               return $row ? $row->pagecount : false;
        }
 }