* (bug 18698) Renaming non entry point maintenance scripts from .inc.php to .inc
[lhc/web/wiklou.git] / maintenance / updateArticleCount.php
1 <?php
2 /**
3 * Maintenance script to provide a better count of the number of articles
4 * and update the site statistics table, if desired
5 *
6 * @file
7 * @ingroup Maintenance
8 * @author Rob Church <robchur@gmail.com>
9 */
10
11 $options = array( 'update', 'help' );
12 require_once( 'commandLine.inc' );
13 require_once( 'updateArticleCount.inc' );
14 echo( "Update Article Count\n\n" );
15
16 if( isset( $options['help'] ) && $options['help'] ) {
17 echo( "Usage: php updateArticleCount.php [--update]\n\n" );
18 echo( "--update : Update site statistics table\n" );
19 exit( 0 );
20 }
21
22 echo( "Counting articles..." );
23 $counter = new ArticleCounter();
24 $result = $counter->count();
25
26 if( $result !== false ) {
27 echo( "found {$result}.\n" );
28 if( isset( $options['update'] ) && $options['update'] ) {
29 echo( "Updating site statistics table... " );
30 $dbw = wfGetDB( DB_MASTER );
31 $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ );
32 echo( "done.\n" );
33 } else {
34 echo( "To update the site statistics table, run the script with the --update option.\n" );
35 }
36 } else {
37 echo( "failed.\n" );
38 }
39 echo( "\n" );
40