MediaWiki  REL1_19
updateArticleCount.php
Go to the documentation of this file.
00001 <?php
00026 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
00027 
00028 class UpdateArticleCount extends Maintenance {
00029 
00030         public function __construct() {
00031                 parent::__construct();
00032                 $this->mDescription = "Count of the number of articles and update the site statistics table";
00033                 $this->addOption( 'update', 'Update the site_stats table with the new count' );
00034         }
00035 
00036         public function execute() {
00037                 $this->output( "Counting articles..." );
00038 
00039                 $counter = new SiteStatsInit( false );
00040                 $result = $counter->articles();
00041 
00042                 $this->output( "found {$result}.\n" );
00043                 if ( $this->hasOption( 'update' ) ) {
00044                         $this->output( "Updating site statistics table... " );
00045                         $dbw = wfGetDB( DB_MASTER );
00046                         $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ );
00047                         $this->output( "done.\n" );
00048                 } else {
00049                         $this->output( "To update the site statistics table, run the script with the --update option.\n" );
00050                 }
00051         }
00052 }
00053 
00054 $maintClass = "UpdateArticleCount";
00055 require_once( RUN_MAINTENANCE_IF_MAIN );