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();
153 return $cache->getWithSetCallback(
154 $cache->makeKey(
'SiteStats',
'groupcounts', $group ),
158 $setOpts += Database::getCacheSetOptions(
$dbr );
160 return (
int)
$dbr->selectField(
164 'ug_group' => $group,
165 'ug_expiry IS NULL OR ug_expiry >= ' .
$dbr->addQuotes(
$dbr->timestamp() )
170 [
'pcTTL' => $cache::TTL_PROC_LONG ]
178 public static function jobs() {
179 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
181 return $cache->getWithSetCallback(
182 $cache->makeKey(
'SiteStats',
'jobscount' ),
192 [
'pcTTL' => $cache::TTL_PROC_LONG ]
201 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
203 return $cache->getWithSetCallback(
204 $cache->makeKey(
'SiteStats',
'page-in-namespace', $ns ),
208 $setOpts += Database::getCacheSetOptions(
$dbr );
210 return (
int)
$dbr->selectField(
213 [
'page_namespace' => $ns ],
217 [
'pcTTL' => $cache::TTL_PROC_LONG ]
242 self::selectFields(),
243 [
'ss_row_id' => 1 ],
258 ||
$row->ss_total_pages <
$row->ss_good_articles
259 ||
$row->ss_total_edits <
$row->ss_total_pages
271 if (
$row->$member < 0 ) {
286 $map += array_fill_keys( self::selectFields(), 0 );
288 foreach ( $map
as $field =>
$value ) {
289 $map[$field] = max( 0,
$value );
299 return MediaWikiServices::getInstance()->getDBLoadBalancer();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static singleton( $domain=false)
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.
Static accessor class for site_stats and related things.
static jobs()
Total number of jobs in the job queue.
static salvageInsaneRow( $row)
static isRowSane( $row)
Is the provided row of site stats sane, or should it be regenerated?
static doLoadFromDB(IDatabase $db)
static unload()
Trigger a reload next time a field is accessed.
static numberingroup( $group)
Find the number of users in a given user group.
when a variable name is used in a function
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
the array() calling protocol came about after MediaWiki 1.4rc1.
returning false will NOT prevent logging $e
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