*/
class SiteStats {
static $row, $loaded = false;
- static $admins;
+ static $admins, $jobs;
static $pageCount = array();
static function recache() {
$dbr = wfGetDB( DB_SLAVE );
self::$row = $dbr->selectRow( 'site_stats', '*', false, __METHOD__ );
}
+
+ self::$loaded = true;
}
static function loadAndLazyInit() {
return self::$admins;
}
+ static function jobs() {
+ if ( !isset( self::$jobs ) ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ self::$jobs = $dbr->estimateRowCount('job');
+ /* 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;
+ }
+
static function pagesInNs( $ns ) {
wfProfileIn( __METHOD__ );
if( !isset( self::$pageCount[$ns] ) ) {
$images = SiteStats::images();
$total = SiteStats::pages();
$users = SiteStats::users();
-
- $admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), $fname );
- $numJobs = $dbr->estimateRowCount('job');
- /* Zero rows still do single row read for row that doesn't exist, but people are annoyed by that */
- if ($numJobs == 1) {
- $numJobs = 0;
- }
+ $admins = SiteStats::admins();
+ $numJobs = SiteStats::jobs();
if ($action == 'raw') {
$wgOut->disable();