Go to the documentation of this file.
42 protected static function load() {
43 if ( self::$row ===
null ) {
52 $config = MediaWikiServices::getInstance()->getMainConfig();
56 wfDebug( __METHOD__ .
": reading site_stats from replica DB\n" );
59 if ( !self::isRowSane(
$row ) && $lb->hasOrMadeRecentMasterChanges() ) {
61 wfDebug( __METHOD__ .
": site_stats damaged or missing on replica DB\n" );
65 if ( !self::isRowSane(
$row ) ) {
66 if ( $config->get(
'MiserMode' ) ) {
75 wfDebug( __METHOD__ .
": initializing damaged or missing site_stats\n" );
82 if ( !self::isRowSane(
$row ) ) {
83 wfDebug( __METHOD__ .
": site_stats persistently nonsensical o_O\n" );
94 public static function edits() {
97 return (
int)self::$row->ss_total_edits;
106 return (
int)self::$row->ss_good_articles;
115 return (
int)self::$row->ss_total_pages;
124 return (
int)self::$row->ss_users;
133 return (
int)self::$row->ss_active_users;
142 return (
int)self::$row->ss_images;
151 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
154 return $cache->getWithSetCallback(
155 $cache->makeKey(
'SiteStats',
'groupcounts', $group ),
157 function ( $oldValue, &$ttl,
array &$setOpts )
use ( $group,
$fname ) {
159 $setOpts += Database::getCacheSetOptions(
$dbr );
161 return (
int)
$dbr->selectField(
165 'ug_group' => $group,
166 'ug_expiry IS NULL OR ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() )
171 [
'pcTTL' => $cache::TTL_PROC_LONG ]
179 public static function jobs() {
180 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
182 return $cache->getWithSetCallback(
183 $cache->makeKey(
'SiteStats',
'jobscount' ),
185 function ( $oldValue, &$ttl,
array &$setOpts ) {
193 [
'pcTTL' => $cache::TTL_PROC_LONG ]
202 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
205 return $cache->getWithSetCallback(
206 $cache->makeKey(
'SiteStats',
'page-in-namespace', $ns ),
208 function ( $oldValue, &$ttl,
array &$setOpts )
use ( $ns,
$fname ) {
210 $setOpts += Database::getCacheSetOptions(
$dbr );
212 return (
int)
$dbr->selectField(
215 [
'page_namespace' => $ns ],
219 [
'pcTTL' => $cache::TTL_PROC_LONG ]
244 self::selectFields(),
245 [
'ss_row_id' => 1 ],
260 ||
$row->ss_total_pages <
$row->ss_good_articles
261 ||
$row->ss_total_edits <
$row->ss_total_pages
273 if (
$row->$member < 0 ) {
288 $map += array_fill_keys( self::selectFields(), 0 );
290 foreach ( $map
as $field =>
$value ) {
291 $map[$field] = max( 0,
$value );
301 return MediaWikiServices::getInstance()->getDBLoadBalancer();
static doAllAndCommit( $database, array $options=[])
Do all updates and commit them.
static isRowSane( $row)
Is the provided row of site stats sane, or should it be regenerated?
static numberingroup( $group)
Find the number of users in a given user group.
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
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static unload()
Trigger a reload next time a field is accessed.
static doLoadFromDB(IDatabase $db)
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
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.
static singleton( $domain=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
static salvageInsaneRow( $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
static doPlaceholderInit()
Insert a dummy row with all zeroes if no row is present.