42 protected static function load() {
43 if ( self::$row ===
null ) {
52 $config = MediaWikiServices::getInstance()->getMainConfig();
56 wfDebug( __METHOD__ .
": reading site_stats from replica DB" );
59 if ( !self::isRowSane(
$row ) && $lb->hasOrMadeRecentMasterChanges() ) {
61 wfDebug( __METHOD__ .
": site_stats damaged or missing on replica DB" );
65 if ( !self::isRowSane(
$row ) ) {
66 if ( $config->get(
'MiserMode' ) ) {
75 wfDebug( __METHOD__ .
": initializing damaged or missing site_stats" );
82 if ( !self::isRowSane(
$row ) ) {
83 wfDebug( __METHOD__ .
": site_stats persistently nonsensical o_O" );
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 ) {
187 $jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() );
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();
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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.