47 $this->dbr = $database;
48 } elseif ( $database ) {
60 $this->
edits = $this->dbr->selectField(
'revision',
'COUNT(*)',
'', __METHOD__ );
61 $this->
edits += $this->dbr->selectField(
'archive',
'COUNT(*)',
'', __METHOD__ );
71 $services = MediaWikiServices::getInstance();
75 'page_namespace' => $services->getNamespaceInfo()->getContentNamespaces(),
76 'page_is_redirect' => 0,
79 if ( $services->getMainConfig()->get(
'ArticleCountMethod' ) ==
'link' ) {
80 $tables[] =
'pagelinks';
81 $conds[] =
'pl_from=page_id';
84 $this->
articles = $this->dbr->selectField(
86 'COUNT(DISTINCT page_id)',
99 $this->
pages = $this->dbr->selectField(
'page',
'COUNT(*)',
'', __METHOD__ );
109 $this->
users = $this->dbr->selectField(
'user',
'COUNT(*)',
'', __METHOD__ );
119 $this->
files = $this->dbr->selectField(
'image',
'COUNT(*)',
'', __METHOD__ );
135 $options += [
'update' =>
false,
'activeUsers' => false ];
138 $counter =
new self( $database );
141 $counter->articles();
149 if ( $options[
'activeUsers'] ) {
150 SiteStatsUpdate::cacheUpdate( self::getDB(
DB_MASTER ) );
159 $exists = $dbw->selectField(
'site_stats',
'1', [
'ss_row_id' => 1 ], __METHOD__ );
160 if ( $exists ===
false ) {
181 $row = [
'ss_row_id' => 1 ] + $set;
197 private static function getDB( $index, $groups = [] ) {
198 return MediaWikiServices::getInstance()
199 ->getDBLoadBalancer()
200 ->getConnectionRef( $index, $groups );
Class designed for counting of stats.
edits()
Count the total number of edits.
pages()
Count total pages.
articles()
Count pages in article space(s)
static doAllAndCommit( $database, array $options=[])
Do all updates and commit them.
static doPlaceholderInit()
Insert a dummy row with all zeroes if no row is present.
files()
Count total files.
static getDB( $index, $groups=[])
refresh()
Refresh site_stats.
users()
Count total users.
__construct( $database=false)