40 self::$loaded =
false;
50 static function load( $recache =
false ) {
51 if ( self::$loaded && !$recache ) {
55 self::$row = self::loadAndLazyInit();
57 # This code is somewhat schema-agnostic, because I'm changing it in a minor release -- TS
58 if ( !isset( self::$row->ss_total_pages ) && self::$row->ss_total_pages == -1 ) {
74 wfDebug( __METHOD__ .
": reading site_stats from replica DB\n" );
77 if ( !self::isSane(
$row ) ) {
79 wfDebug( __METHOD__ .
": site_stats damaged or missing on replica DB\n" );
83 if ( !$wgMiserMode && !self::isSane(
$row ) ) {
88 wfDebug( __METHOD__ .
": initializing damaged or missing site_stats\n" );
95 if ( !self::isSane(
$row ) ) {
96 wfDebug( __METHOD__ .
": site_stats persistently nonsensical o_O\n" );
106 return $db->selectRow(
'site_stats', [
135 return self::$row->ss_total_edits;
143 return self::$row->ss_good_articles;
151 return self::$row->ss_total_pages;
159 return self::$row->ss_users;
167 return self::$row->ss_active_users;
175 return self::$row->ss_images;
185 return $cache->getWithSetCallback(
186 wfMemcKey(
'SiteStats',
'groupcounts', $group ),
188 function ( $oldValue, &$ttl,
array &$setOpts )
use ( $group ) {
193 return $dbr->selectField(
196 [
'ug_group' => $group ],
200 [
'pcTTL' => $cache::TTL_PROC_LONG ]
208 if ( !isset( self::$jobs ) ) {
218 if ( self::$jobs == 1 ) {
231 if ( !isset( self::$pageCount[$ns] ) ) {
233 self::$pageCount[$ns] = (int)
$dbr->selectField(
236 [
'page_namespace' => $ns ],
240 return self::$pageCount[$ns];
254 ||
$row->ss_total_pages <
$row->ss_good_articles
255 ||
$row->ss_total_edits <
$row->ss_total_pages
267 if (
$row->$member > 2000000000 ||
$row->$member < 0 ) {
295 $this->db = $database;
296 } elseif ( $database ) {
308 $this->mEdits = $this->db->selectField(
'revision',
'COUNT(*)',
'', __METHOD__ );
309 $this->mEdits += $this->db->selectField(
'archive',
'COUNT(*)',
'', __METHOD__ );
318 global $wgArticleCountMethod;
323 'page_is_redirect' => 0,
326 if ( $wgArticleCountMethod ==
'link' ) {
328 $conds[] =
'pl_from=page_id';
329 } elseif ( $wgArticleCountMethod ==
'comma' ) {
335 $conds[] =
'page_len > 0';
338 $this->mArticles = $this->db->selectField(
$tables,
'COUNT(DISTINCT page_id)',
339 $conds, __METHOD__ );
348 $this->mPages = $this->db->selectField(
'page',
'COUNT(*)',
'', __METHOD__ );
357 $this->mUsers = $this->db->selectField(
'user',
'COUNT(*)',
'', __METHOD__ );
366 $this->mFiles = $this->db->selectField(
'image',
'COUNT(*)',
'', __METHOD__ );
387 $counter->articles();
414 $dbw->upsert(
'site_stats', $values, [
'ss_row_id' ], $values, __METHOD__ );
static getMainWANInstance()
Get the main WAN cache object.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
files()
Count total files.
the array() calling protocol came about after MediaWiki 1.4rc1.
static bool stdClass $row
processing should stop and the error should be shown to the user * false
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
static getCacheSetOptions(IDatabase $db1)
Merge the result of getSessionLagStatus() for several DBs using the most pessimistic values to estima...
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load
when a variable name is used in a it is silently declared as a new local masking the global
static doAllAndCommit($database, array $options=[])
Do all updates and commit them.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
pages()
Count total pages.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static views()
Return the total number of page views.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
$wgMiserMode
Disable database-intensive features.
Class for handling updates to the site_stats table.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
Class designed for counting of stats.
Static accessor class for site_stats and related things.
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
static singleton($wiki=false)
refresh()
Refresh site_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
static load($recache=false)
edits()
Count the total number of edits.
__construct($database=false)
Constructor.
wfMemcKey()
Make a cache key for the local wiki.
users()
Count total users.
static numberingroup($group)
Find the number of users in a given user group.
articles()
Count pages in article space(s)
static isSane($row)
Is the provided row of site stats sane, or should it be regenerated?
Basic database interface for live and lazy-loaded relation database handles.