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 ),
156 function ( $oldValue, &$ttl, array &$setOpts ) use ( $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' ),
184 function ( $oldValue, &$ttl, array &$setOpts ) {
192 [
'pcTTL' => $cache::TTL_PROC_LONG ]
201 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
203 return $cache->getWithSetCallback(
204 $cache->makeKey(
'SiteStats',
'page-in-namespace', $ns ),
206 function ( $oldValue, &$ttl, array &$setOpts ) use ( $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();
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
the array() calling protocol came about after MediaWiki 1.4rc1.
returning false will NOT prevent logging $e