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