49 $this->dbr = $database;
50 } elseif ( $database ) {
62 $this->
edits = $this->dbr->selectField(
'revision',
'COUNT(*)',
'', __METHOD__ );
63 $this->
edits += $this->dbr->selectField(
'archive',
'COUNT(*)',
'', __METHOD__ );
73 $services = MediaWikiServices::getInstance();
77 'page_namespace' => $services->getNamespaceInfo()->getContentNamespaces(),
78 'page_is_redirect' => 0,
81 if ( $services->getMainConfig()->get( MainConfigNames::ArticleCountMethod ) ==
'link' ) {
82 $tables[] =
'pagelinks';
83 $conds[] =
'pl_from=page_id';
86 $this->
articles = $this->dbr->selectField(
88 'COUNT(DISTINCT page_id)',
101 $this->
pages = $this->dbr->selectField(
'page',
'COUNT(*)',
'', __METHOD__ );
111 $this->
users = $this->dbr->selectField(
'user',
'COUNT(*)',
'', __METHOD__ );
121 $this->
files = $this->dbr->selectField(
'image',
'COUNT(*)',
'', __METHOD__ );
137 $options += [
'update' =>
false,
'activeUsers' => false ];
140 $counter =
new self( $database );
143 $counter->articles();
151 if ( $options[
'activeUsers'] ) {
161 $exists = (bool)$dbw->selectField(
'site_stats',
'1', [
'ss_row_id' => 1 ], __METHOD__ );
177 'ss_total_edits' => $this->
edits ?? $this->
edits(),
179 'ss_total_pages' => $this->
pages ?? $this->
pages(),
181 'ss_images' => $this->
files ?? $this->
files(),
183 $row = [
'ss_row_id' => 1 ] + $set;
199 private static function getDB( $index, $groups = [] ) {
200 return MediaWikiServices::getInstance()
201 ->getDBLoadBalancer()
202 ->getConnectionRef( $index, $groups );
A class containing constants representing the names of configuration variables.
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)
static cacheUpdate(IDatabase $dbw)