r38136 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38135‎ | r38136 | r38137 >
Date:15:49, 28 July 2008
Author:demon
Status:old
Tags:
Comment:
Deprecate SiteStats::admins() in favor of SiteStats::numberingroup('sysop'). Should make bug 13471 easy.
Modified paths:
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser_OldPP.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialStatistics.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SiteStats.php
@@ -7,6 +7,7 @@
88 static $row, $loaded = false;
99 static $admins, $jobs;
1010 static $pageCount = array();
 11+ static $groupMemberCounts = array();
1112
1213 static function recache() {
1314 self::load( true );
@@ -98,12 +99,26 @@
99100 return self::$row->ss_images;
100101 }
101102
 103+ /**
 104+ * @deprecated Use self::numberingroup('sysop') instead
 105+ */
102106 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] ) ) {
104118 $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__ );
106121 }
107 - return self::$admins;
 122+ return self::$groupMemberCounts[$group];
108123 }
109124
110125 static function jobs() {
Index: trunk/phase3/includes/parser/Parser_OldPP.php
@@ -2544,7 +2544,7 @@
25452545 case 'numberofpages':
25462546 return $varCache[$index] = $wgContLang->formatNum( SiteStats::pages() );
25472547 case 'numberofadmins':
2548 - return $varCache[$index] = $wgContLang->formatNum( SiteStats::admins() );
 2548+ return $varCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') );
25492549 case 'numberofedits':
25502550 return $varCache[$index] = $wgContLang->formatNum( SiteStats::edits() );
25512551 case 'currenttimestamp':
Index: trunk/phase3/includes/parser/Parser.php
@@ -2548,7 +2548,7 @@
25492549 case 'numberofpages':
25502550 return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::pages() );
25512551 case 'numberofadmins':
2552 - return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::admins() );
 2552+ return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') );
25532553 case 'numberofedits':
25542554 return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::edits() );
25552555 case 'currenttimestamp':
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -207,7 +207,7 @@
208208 return self::formatRaw( SiteStats::images(), $raw );
209209 }
210210 static function numberofadmins( $parser, $raw = null ) {
211 - return self::formatRaw( SiteStats::admins(), $raw );
 211+ return self::formatRaw( SiteStats::numberingroup('sysop'), $raw );
212212 }
213213 static function numberofedits( $parser, $raw = null ) {
214214 return self::formatRaw( SiteStats::edits(), $raw );
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -239,7 +239,7 @@
240240 $data['edits'] = intval( SiteStats::edits() );
241241 $data['images'] = intval( SiteStats::images() );
242242 $data['users'] = intval( SiteStats::users() );
243 - $data['admins'] = intval( SiteStats::admins() );
 243+ $data['admins'] = intval( SiteStats::numberingroup('sysop') );
244244 $data['jobs'] = intval( SiteStats::jobs() );
245245 $this->getResult()->addValue( 'query', $property, $data );
246246 }
Index: trunk/phase3/includes/specials/SpecialStatistics.php
@@ -23,7 +23,7 @@
2424 $images = SiteStats::images();
2525 $total = SiteStats::pages();
2626 $users = SiteStats::users();
27 - $admins = SiteStats::admins();
 27+ $admins = SiteStats::numberingroup('sysop');
2828 $numJobs = SiteStats::jobs();
2929
3030 if( $wgRequest->getVal( 'action' ) == 'raw' ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r40116(bug 13471) Added NUMBERINGROUP magic word. Patch by Soxred93catrope00:04, 28 August 2008

Status & tagging log