Fix XmlTypeCheck docs
[mediawiki.git] / maintenance / updateArticleCount.php
blob7964a21f82234d8a83087187e57dee97c18cd392
1 <?php
2 /**
3 * Provide a better count of the number of articles
4 * and update the site statistics table, if desired.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @file
22 * @ingroup Maintenance
23 * @author Rob Church <robchur@gmail.com>
26 require_once __DIR__ . '/Maintenance.php';
28 /**
29 * Maintenance script to provide a better count of the number of articles
30 * and update the site statistics table, if desired.
32 * @ingroup Maintenance
34 class UpdateArticleCount extends Maintenance {
36 public function __construct() {
37 parent::__construct();
38 $this->mDescription = "Count of the number of articles and update the site statistics table";
39 $this->addOption( 'update', 'Update the site_stats table with the new count' );
42 public function execute() {
43 $this->output( "Counting articles..." );
45 $counter = new SiteStatsInit( false );
46 $result = $counter->articles();
48 $this->output( "found {$result}.\n" );
49 if ( $this->hasOption( 'update' ) ) {
50 $this->output( "Updating site statistics table... " );
51 $dbw = wfGetDB( DB_MASTER );
52 $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ );
53 $this->output( "done.\n" );
54 } else {
55 $this->output( "To update the site statistics table, run the script with the --update option.\n" );
60 $maintClass = "UpdateArticleCount";
61 require_once RUN_MAINTENANCE_IF_MAIN;