From: Yuri Astrakhan Date: Thu, 9 Aug 2007 12:27:50 +0000 (+0000) Subject: Statistics code cleanup, fixed multiple db reload bug. X-Git-Tag: 1.31.0-rc.0~51814 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=fa3c83c114068015697c65b718e652eba7deac74;p=lhc%2Fweb%2Fwiklou.git Statistics code cleanup, fixed multiple db reload bug. --- diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 65e3eb0080..d7b9161ab0 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -5,7 +5,7 @@ */ class SiteStats { static $row, $loaded = false; - static $admins; + static $admins, $jobs; static $pageCount = array(); static function recache() { @@ -27,6 +27,8 @@ class SiteStats { $dbr = wfGetDB( DB_SLAVE ); self::$row = $dbr->selectRow( 'site_stats', '*', false, __METHOD__ ); } + + self::$loaded = true; } static function loadAndLazyInit() { @@ -104,6 +106,18 @@ class SiteStats { 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] ) ) { diff --git a/includes/SpecialStatistics.php b/includes/SpecialStatistics.php index 5fb68f8ffc..6343edd13f 100644 --- a/includes/SpecialStatistics.php +++ b/includes/SpecialStatistics.php @@ -21,13 +21,8 @@ function wfSpecialStatistics() { $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();