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