r24696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24695‎ | r24696 | r24697 >
Date:12:27, 9 August 2007
Author:yurik
Status:old
Tags:
Comment:
Statistics code cleanup, fixed multiple db reload bug.
Modified paths:
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/includes/SpecialStatistics.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SiteStats.php
@@ -5,7 +5,7 @@
66 */
77 class SiteStats {
88 static $row, $loaded = false;
9 - static $admins;
 9+ static $admins, $jobs;
1010 static $pageCount = array();
1111
1212 static function recache() {
@@ -27,6 +27,8 @@
2828 $dbr = wfGetDB( DB_SLAVE );
2929 self::$row = $dbr->selectRow( 'site_stats', '*', false, __METHOD__ );
3030 }
 31+
 32+ self::$loaded = true;
3133 }
3234
3335 static function loadAndLazyInit() {
@@ -104,6 +106,18 @@
105107 return self::$admins;
106108 }
107109
 110+ static function jobs() {
 111+ if ( !isset( self::$jobs ) ) {
 112+ $dbr = wfGetDB( DB_SLAVE );
 113+ self::$jobs = $dbr->estimateRowCount('job');
 114+ /* Zero rows still do single row read for row that doesn't exist, but people are annoyed by that */
 115+ if (self::$jobs == 1) {
 116+ self::$jobs = 0;
 117+ }
 118+ }
 119+ return self::$jobs;
 120+ }
 121+
108122 static function pagesInNs( $ns ) {
109123 wfProfileIn( __METHOD__ );
110124 if( !isset( self::$pageCount[$ns] ) ) {
Index: trunk/phase3/includes/SpecialStatistics.php
@@ -21,14 +21,9 @@
2222 $images = SiteStats::images();
2323 $total = SiteStats::pages();
2424 $users = SiteStats::users();
 25+ $admins = SiteStats::admins();
 26+ $numJobs = SiteStats::jobs();
2527
26 - $admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), $fname );
27 - $numJobs = $dbr->estimateRowCount('job');
28 - /* Zero rows still do single row read for row that doesn't exist, but people are annoyed by that */
29 - if ($numJobs == 1) {
30 - $numJobs = 0;
31 - }
32 -
3328 if ($action == 'raw') {
3429 $wgOut->disable();
3530 header( 'Pragma: nocache' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r24755Merged revisions 24694-24754 via svnmerge from...david19:48, 13 August 2007

Status & tagging log