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();