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__ );
329 'page_namespace' => MWNamespace::getContentNamespaces(),
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__ );
$wgArticleCountMethod
Method used to determine if a page in a content namespace should be counted as a valid article.
$wgMiserMode
Disable database-intensive features.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static singleton( $wiki=false)
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.
files()
Count total files.
refresh()
Refresh site_stats.
users()
Count total users.
__construct( $database=false)
Class for handling updates to the site_stats table.
static cacheUpdate( $dbw)
Static accessor class for site_stats and related things.
static isSane( $row)
Is the provided row of site stats sane, or should it be regenerated?
static jobs()
Total number of jobs in the job queue.
static views()
Return the total number of page views.
static load( $recache=false)
static bool stdClass $row
static numberingroup( $group)
Find the number of users in a given user group.
when a variable name is used in a function
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
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
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load