updateArticleCount.php: use "vslow" DB by default, allow master
authorFederico Leva <federicoleva@tiscali.it>
Tue, 9 Dec 2014 14:50:56 +0000 (15:50 +0100)
committerReedy <reedy@wikimedia.org>
Tue, 9 Dec 2014 19:20:10 +0000 (19:20 +0000)
Similar to initSiteStats.php, SiteStatsUpdate.php.
Needed by I13f866b565f665a00ec6ce61bb5073cf380bd0ff

Bug: T68867
Change-Id: I061b1bd7bd4b84db5ca4ecf406980dd6981941d1

maintenance/updateArticleCount.php

index 470647a..55f535d 100644 (file)
@@ -37,12 +37,18 @@ class UpdateArticleCount extends Maintenance {
                parent::__construct();
                $this->mDescription = "Count of the number of articles and update the site statistics table";
                $this->addOption( 'update', 'Update the site_stats table with the new count' );
+               $this->addOption( 'use-master', 'Count using the master database' );
        }
 
        public function execute() {
                $this->output( "Counting articles..." );
 
-               $counter = new SiteStatsInit( false );
+               if ( $this->hasOption( 'use-master' ) ) {
+                       $dbr = wfGetDB( DB_MASTER );
+               } else {
+                       $dbr = wfGetDB( DB_SLAVE, 'vslow' );
+               }
+               $counter = new SiteStatsInit( $dbr );
                $result = $counter->articles();
 
                $this->output( "found {$result}.\n" );