X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSiteStats.php;h=d253805589b51471cd3bef86aae9b61ad08b6495;hb=e86a6310f748ae00d8575908b9f9eb2540a104aa;hp=1c7730c971ac3acf44fa901ccb7ce0a27b5893e7;hpb=37198b7d358963bddec354e17bad696b5ea4c476;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 1c7730c971..d253805589 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -22,6 +22,7 @@ use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; +use MediaWiki\MediaWikiServices; /** * Static accessor class for site_stats and related things @@ -78,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 ) ) { @@ -98,6 +102,7 @@ class SiteStats { if ( !self::isSane( $row ) ) { wfDebug( __METHOD__ . ": site_stats persistently nonsensical o_O\n" ); } + return $row; } @@ -189,7 +194,6 @@ class SiteStats { wfMemcKey( 'SiteStats', 'groupcounts', $group ), $cache::TTL_HOUR, function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) { - global $wgDisableUserGroupExpiry; $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); @@ -199,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__ );