X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSiteStats.php;h=6a2d0e2adada89fe64ed1bbf65da995ff814fdc0;hb=79ef473a2f558438c6846d046afe2e31db042722;hp=ac5e49e70e5853c89d0d3cc3c5b6efc86c7277ac;hpb=6f466c166e3ba5ea8f2e1a37bc32d3c02901c3e0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteStats.php b/includes/SiteStats.php index ac5e49e70e..6a2d0e2ada 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -34,9 +34,6 @@ class SiteStats { /** @var bool */ private static $loaded = false; - /** @var int */ - private static $jobs; - /** @var int[] */ private static $pageCount = []; @@ -189,12 +186,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 ); @@ -204,9 +200,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__ ); @@ -216,24 +210,24 @@ class SiteStats { } /** + * Total number of jobs in the job queue. * @return int */ static function jobs() { - if ( !isset( self::$jobs ) ) { - try{ - self::$jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() ); - } catch ( JobQueueError $e ) { - self::$jobs = 0; - } - /** - * Zero rows still do single row read for row that doesn't exist, - * but people are annoyed by that - */ - if ( self::$jobs == 1 ) { - self::$jobs = 0; - } - } - return self::$jobs; + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + return $cache->getWithSetCallback( + $cache->makeKey( 'SiteStats', 'jobscount' ), + $cache::TTL_MINUTE, + function ( $oldValue, &$ttl, array &$setOpts ) { + try{ + $jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() ); + } catch ( JobQueueError $e ) { + $jobs = 0; + } + return $jobs; + }, + [ 'pcTTL' => $cache::TTL_PROC_LONG ] + ); } /** @@ -299,7 +293,6 @@ class SiteStatsInit { private $mUsers = null, $mFiles = null; /** - * Constructor * @param bool|IDatabase $database * - boolean: Whether to use the master DB * - IDatabase: Database connection to use