MediaWiki  1.23.14
initSiteStats.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/Maintenance.php';
27 
33 class InitSiteStats extends Maintenance {
34  public function __construct() {
35  parent::__construct();
36  $this->mDescription = "Re-initialise the site statistics tables";
37  $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
38  $this->addOption( 'noviews', "Don't update the page view counter" );
39  $this->addOption( 'active', 'Also update active users count' );
40  $this->addOption( 'use-master', 'Count using the master database' );
41  }
42 
43  public function execute() {
44  $this->output( "Refresh Site Statistics\n\n" );
45  $counter = new SiteStatsInit( $this->hasOption( 'use-master' ) );
46 
47  $this->output( "Counting total edits..." );
48  $edits = $counter->edits();
49  $this->output( "{$edits}\nCounting number of articles..." );
50 
51  $good = $counter->articles();
52  $this->output( "{$good}\nCounting total pages..." );
53 
54  $pages = $counter->pages();
55  $this->output( "{$pages}\nCounting number of users..." );
56 
57  $users = $counter->users();
58  $this->output( "{$users}\nCounting number of images..." );
59 
60  $image = $counter->files();
61  $this->output( "{$image}\n" );
62 
63  if ( !$this->hasOption( 'noviews' ) ) {
64  $this->output( "Counting total page views..." );
65  $views = $counter->views();
66  $this->output( "{$views}\n" );
67  }
68 
69  if ( $this->hasOption( 'update' ) ) {
70  $this->output( "\nUpdating site statistics..." );
71  $counter->refresh();
72  $this->output( "done.\n" );
73  }
74 
75  if ( $this->hasOption( 'active' ) ) {
76  $this->output( "\nCounting and updating active users..." );
78  $this->output( "{$active}\n" );
79  }
80 
81  $this->output( "\nDone.\n" );
82  }
83 }
84 
85 $maintClass = "InitSiteStats";
86 require_once RUN_MAINTENANCE_IF_MAIN;
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SiteStatsUpdate\cacheUpdate
static cacheUpdate( $dbw)
Definition: SiteStatsUpdate.php:129
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
SiteStatsInit
Class designed for counting of stats.
Definition: SiteStats.php:257
InitSiteStats\execute
execute()
Do the actual work.
Definition: initSiteStats.php:43
InitSiteStats\__construct
__construct()
Default constructor.
Definition: initSiteStats.php:34
$maintClass
$maintClass
Definition: initSiteStats.php:85
InitSiteStats
Maintenance script to re-initialise or update the site statistics table.
Definition: initSiteStats.php:33
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181