X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSiteStats.php;h=6ce1aed814022e036ee0e06b50b8e6943f5f222d;hb=a12d8aeb225acfbf9cc2794f4cbca9c5fc0fe6fb;hp=bc6b84248ca208f92fd196b17018debe37f94d7f;hpb=b170b4a14a94fb509c4b15ca4c5717c6976a32cc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteStats.php b/includes/SiteStats.php index bc6b84248c..6ce1aed814 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -20,7 +20,9 @@ * @file */ +use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; +use MediaWiki\MediaWikiServices; /** * Static accessor class for site_stats and related things @@ -77,9 +79,12 @@ class SiteStats { $row = self::doLoad( wfGetDB( DB_REPLICA ) ); if ( !self::isSane( $row ) ) { - // Might have just been initialized during this request? Underflow? - wfDebug( __METHOD__ . ": site_stats damaged or missing on replica DB\n" ); - $row = self::doLoad( wfGetDB( DB_MASTER ) ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + if ( $lb->hasOrMadeRecentMasterChanges() ) { + // Might have just been initialized during this request? Underflow? + wfDebug( __METHOD__ . ": site_stats damaged or missing on replica DB\n" ); + $row = self::doLoad( wfGetDB( DB_MASTER ) ); + } } if ( !$wgMiserMode && !self::isSane( $row ) ) { @@ -97,6 +102,7 @@ class SiteStats { if ( !self::isSane( $row ) ) { wfDebug( __METHOD__ . ": site_stats persistently nonsensical o_O\n" ); } + return $row; } @@ -183,12 +189,11 @@ class SiteStats { * @return int */ static function numberingroup( $group ) { - $cache = ObjectCache::getMainWANInstance(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); return $cache->getWithSetCallback( - wfMemcKey( 'SiteStats', 'groupcounts', $group ), + $cache->makeKey( 'SiteStats', 'groupcounts', $group ), $cache::TTL_HOUR, function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) { - global $wgDisableUserGroupExpiry; $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); @@ -198,9 +203,7 @@ class SiteStats { 'COUNT(*)', [ 'ug_group' => $group, - $wgDisableUserGroupExpiry ? - '1' : - 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ) + 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ) ], __METHOD__ );