Go to the documentation of this file.
41 self::$loaded =
false;
51 static function load( $recache =
false ) {
52 if ( self::$loaded && !$recache ) {
58 # This code is somewhat schema-agnostic, because I'm changing it in a minor release -- TS
59 if ( !isset( self::$row->ss_total_pages ) && self::$row->ss_total_pages == -1 ) {
75 wfDebug( __METHOD__ .
": reading site_stats from replica DB\n" );
78 if ( !self::isSane(
$row ) ) {
79 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
80 if ( $lb->hasOrMadeRecentMasterChanges() ) {
82 wfDebug( __METHOD__ .
": site_stats damaged or missing on replica DB\n" );
92 wfDebug( __METHOD__ .
": initializing damaged or missing site_stats\n" );
99 if ( !self::isSane(
$row ) ) {
100 wfDebug( __METHOD__ .
": site_stats persistently nonsensical o_O\n" );
111 return $db->selectRow(
'site_stats', [
140 return self::$row->ss_total_edits;
148 return self::$row->ss_good_articles;
156 return self::$row->ss_total_pages;
164 return self::$row->ss_users;
172 return self::$row->ss_active_users;
180 return self::$row->ss_images;
189 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
190 return $cache->getWithSetCallback(
191 $cache->makeKey(
'SiteStats',
'groupcounts', $group ),
193 function ( $oldValue, &$ttl,
array &$setOpts )
use ( $group ) {
196 $setOpts += Database::getCacheSetOptions(
$dbr );
198 return $dbr->selectField(
202 'ug_group' => $group,
203 'ug_expiry IS NULL OR ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() )
208 [
'pcTTL' => $cache::TTL_PROC_LONG ]
217 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
218 return $cache->getWithSetCallback(
219 $cache->makeKey(
'SiteStats',
'jobscount' ),
221 function ( $oldValue, &$ttl,
array &$setOpts ) {
229 [
'pcTTL' => $cache::TTL_PROC_LONG ]
239 if ( !isset( self::$pageCount[$ns] ) ) {
241 self::$pageCount[$ns] = (int)
$dbr->selectField(
244 [
'page_namespace' => $ns ],
248 return self::$pageCount[$ns];
262 ||
$row->ss_total_pages <
$row->ss_good_articles
263 ||
$row->ss_total_edits <
$row->ss_total_pages
275 if (
$row->$member > 2000000000 ||
$row->$member < 0 ) {
302 $this->db = $database;
303 } elseif ( $database ) {
315 $this->mEdits = $this->db->selectField(
'revision',
'COUNT(*)',
'', __METHOD__ );
316 $this->mEdits += $this->db->selectField(
'archive',
'COUNT(*)',
'', __METHOD__ );
330 'page_is_redirect' => 0,
335 $conds[] =
'pl_from=page_id';
342 $conds[] =
'page_len > 0';
345 $this->mArticles = $this->db->selectField(
$tables,
'COUNT(DISTINCT page_id)',
346 $conds, __METHOD__ );
355 $this->mPages = $this->db->selectField(
'page',
'COUNT(*)',
'', __METHOD__ );
364 $this->mUsers = $this->db->selectField(
'user',
'COUNT(*)',
'', __METHOD__ );
373 $this->mFiles = $this->db->selectField(
'image',
'COUNT(*)',
'', __METHOD__ );
394 $counter->articles();
421 $dbw->upsert(
'site_stats', $values, [
'ss_row_id' ], $values, __METHOD__ );
processing should stop and the error should be shown to the user * false
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
static doAllAndCommit( $database, array $options=[])
Do all updates and commit them.
static cacheUpdate( $dbw)
static isSane( $row)
Is the provided row of site stats sane, or should it be regenerated?
articles()
Count pages in article space(s)
pages()
Count total pages.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static numberingroup( $group)
Find the number of users in a given user group.
static load( $recache=false)
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
Class designed for counting of stats.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
files()
Count total files.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
when a variable name is used in a it is silently declared as a new masking the global
Class for handling updates to the site_stats table.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static jobs()
Total number of jobs in the job queue.
Static accessor class for site_stats and related things.
users()
Count total users.
$wgMiserMode
Disable database-intensive features.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
__construct( $database=false)
static singleton( $wiki=false)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
edits()
Count the total number of edits.
static views()
Return the total number of page views.
$wgArticleCountMethod
Method used to determine if a page in a content namespace should be counted as a valid article.
static bool stdClass $row
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
refresh()
Refresh site_stats.
the array() calling protocol came about after MediaWiki 1.4rc1.