Index: trunk/phase3/includes/SiteStats.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | static $row, $loaded = false; |
9 | 9 | static $admins, $jobs; |
10 | 10 | static $pageCount = array(); |
| 11 | + static $groupMemberCounts = array(); |
11 | 12 | |
12 | 13 | static function recache() { |
13 | 14 | self::load( true ); |
— | — | @@ -98,12 +99,26 @@ |
99 | 100 | return self::$row->ss_images; |
100 | 101 | } |
101 | 102 | |
| 103 | + /** |
| 104 | + * @deprecated Use self::numberingroup('sysop') instead |
| 105 | + */ |
102 | 106 | static function admins() { |
103 | | - if ( !isset( self::$admins ) ) { |
| 107 | + wfDeprecated(__METHOD__); |
| 108 | + return self::numberingroup('sysop'); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Find the number of users in a given user group. |
| 113 | + * @param string $group Name of group |
| 114 | + * @return int |
| 115 | + */ |
| 116 | + static function numberingroup($group) { |
| 117 | + if ( !isset( self::$groupMemberCounts[$group] ) ) { |
104 | 118 | $dbr = wfGetDB( DB_SLAVE ); |
105 | | - self::$admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ ); |
| 119 | + self::$groupMemberCounts[$group] = $dbr->selectField( 'user_groups', 'COUNT(*)', |
| 120 | + array( 'ug_group' => $group ), __METHOD__ ); |
106 | 121 | } |
107 | | - return self::$admins; |
| 122 | + return self::$groupMemberCounts[$group]; |
108 | 123 | } |
109 | 124 | |
110 | 125 | static function jobs() { |
Index: trunk/phase3/includes/parser/Parser_OldPP.php |
— | — | @@ -2544,7 +2544,7 @@ |
2545 | 2545 | case 'numberofpages': |
2546 | 2546 | return $varCache[$index] = $wgContLang->formatNum( SiteStats::pages() ); |
2547 | 2547 | case 'numberofadmins': |
2548 | | - return $varCache[$index] = $wgContLang->formatNum( SiteStats::admins() ); |
| 2548 | + return $varCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); |
2549 | 2549 | case 'numberofedits': |
2550 | 2550 | return $varCache[$index] = $wgContLang->formatNum( SiteStats::edits() ); |
2551 | 2551 | case 'currenttimestamp': |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -2548,7 +2548,7 @@ |
2549 | 2549 | case 'numberofpages': |
2550 | 2550 | return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::pages() ); |
2551 | 2551 | case 'numberofadmins': |
2552 | | - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::admins() ); |
| 2552 | + return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); |
2553 | 2553 | case 'numberofedits': |
2554 | 2554 | return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::edits() ); |
2555 | 2555 | case 'currenttimestamp': |
Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | return self::formatRaw( SiteStats::images(), $raw ); |
209 | 209 | } |
210 | 210 | static function numberofadmins( $parser, $raw = null ) { |
211 | | - return self::formatRaw( SiteStats::admins(), $raw ); |
| 211 | + return self::formatRaw( SiteStats::numberingroup('sysop'), $raw ); |
212 | 212 | } |
213 | 213 | static function numberofedits( $parser, $raw = null ) { |
214 | 214 | return self::formatRaw( SiteStats::edits(), $raw ); |
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php |
— | — | @@ -239,7 +239,7 @@ |
240 | 240 | $data['edits'] = intval( SiteStats::edits() ); |
241 | 241 | $data['images'] = intval( SiteStats::images() ); |
242 | 242 | $data['users'] = intval( SiteStats::users() ); |
243 | | - $data['admins'] = intval( SiteStats::admins() ); |
| 243 | + $data['admins'] = intval( SiteStats::numberingroup('sysop') ); |
244 | 244 | $data['jobs'] = intval( SiteStats::jobs() ); |
245 | 245 | $this->getResult()->addValue( 'query', $property, $data ); |
246 | 246 | } |
Index: trunk/phase3/includes/specials/SpecialStatistics.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | $images = SiteStats::images(); |
25 | 25 | $total = SiteStats::pages(); |
26 | 26 | $users = SiteStats::users(); |
27 | | - $admins = SiteStats::admins(); |
| 27 | + $admins = SiteStats::numberingroup('sysop'); |
28 | 28 | $numJobs = SiteStats::jobs(); |
29 | 29 | |
30 | 30 | if( $wgRequest->getVal( 'action' ) == 'raw' ) { |