MediaWiki  REL1_24
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(
00053                 'site_stats',
00054                 array( 'ss_good_articles' => $result ),
00055                 array( 'ss_row_id' => 1 ),
00056                 __METHOD__
00057             );
00058             $this->output( "done.\n" );
00059         } else {
00060             $this->output( "To update the site statistics table, run the script "
00061                 . "with the --update option.\n" );
00062         }
00063     }
00064 }
00065 
00066 $maintClass = "UpdateArticleCount";
00067 require_once RUN_MAINTENANCE_IF_MAIN;