r69495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69494‎ | r69495 | r69496 >
Date:07:15, 18 July 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Made active users concept have some meaning by decoupling it from recent changes length.

Introduced wgActiveUserDays, which defaults to 30 days as used on wmf.
This way the number can be more easily compared between wikis.
We no longer lie to users if the actual rc length is longer than the limit.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialActiveusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialStatistics.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SiteStats.php
@@ -234,6 +234,7 @@
235235 }
236236
237237 public static function cacheUpdate( $dbw ) {
 238+ global $wgActiveUserDays;
238239 $dbr = wfGetDB( DB_SLAVE, array( 'SpecialStatistics', 'vslow' ) );
239240 # Get non-bot users than did some recent action other than making accounts.
240241 # If account creation is included, the number gets inflated ~20+ fold on enwiki.
@@ -243,7 +244,8 @@
244245 array(
245246 'rc_user != 0',
246247 'rc_bot' => 0,
247 - "rc_log_type != 'newusers' OR rc_log_type IS NULL"
 248+ "rc_log_type != 'newusers' OR rc_log_type IS NULL",
 249+ "rc_timestamp >= '{$dbw->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 )}'",
248250 ),
249251 __METHOD__
250252 );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2715,6 +2715,14 @@
27162716 */
27172717 $wgHitcounterUpdateFreq = 1;
27182718
 2719+/**
 2720+ * How many days user must be idle before he is considered inactive. Will affect
 2721+ * the number shown on Special:Statistics and Special:ActiveUsers special page.
 2722+ * You might want to leave this as the default value, to provide comparable
 2723+ * numbers between different wikis.
 2724+ */
 2725+$wgActiveUserDays = 30;
 2726+
27192727 /** @} */ # End of statistics }
27202728
27212729 /************************************************************************//**
Index: trunk/phase3/includes/specials/SpecialActiveusers.php
@@ -29,9 +29,8 @@
3030 class ActiveUsersPager extends UsersPager {
3131
3232 function __construct( $group = null ) {
33 - global $wgRequest, $wgRCMaxAge;
34 - $this->RCMaxAge = ceil( $wgRCMaxAge / ( 3600 * 24 ) ); // Constant
35 -
 33+ global $wgRequest, $wgActiveUserDays;
 34+ $this->RCMaxAge = $wgActiveUserDays;
3635 $un = $wgRequest->getText( 'username' );
3736 $this->requestedUser = '';
3837 if ( $un != '' ) {
@@ -72,6 +71,7 @@
7372 $conds = array( 'rc_user > 0' ); // Users - no anons
7473 $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
7574 $conds[] = "rc_log_type IS NULL OR rc_log_type != 'newusers'";
 75+ $conds[] = "rc_timestamp >= '{$dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 )}'";
7676
7777 if( $this->requestedUser != '' ) {
7878 $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
@@ -167,7 +167,7 @@
168168 * @param $par Mixed: parameter passed to the page or null
169169 */
170170 public function execute( $par ) {
171 - global $wgOut, $wgLang, $wgRCMaxAge;
 171+ global $wgOut, $wgLang, $wgActiveUserDays;
172172
173173 $this->setHeaders();
174174 $this->outputHeader();
@@ -177,9 +177,9 @@
178178 # getBody() first to check, if empty
179179 $usersbody = $up->getBody();
180180
181 - $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ),
182 - wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( ceil( $wgRCMaxAge / 86400 ) ) )
183 - );
 181+ $s = Html::rawElement( 'div', array( 'class' => 'mw-activeusers-intro' ),
 182+ wfMsgExt( 'activeusers-intro', array( 'parsemag', 'escape' ), $wgLang->formatNum( $wgActiveUserDays ) )
 183+ );
184184
185185 $s .= $up->getPageHeader();
186186 if( $usersbody ) {
Index: trunk/phase3/includes/specials/SpecialStatistics.php
@@ -174,7 +174,7 @@
175175 }
176176
177177 private function getUserStats() {
178 - global $wgLang, $wgUser, $wgRCMaxAge;
 178+ global $wgLang, $wgUser, $wgActiveUserDays;
179179 $sk = $wgUser->getSkin();
180180 return Xml::openElement( 'tr' ) .
181181 Xml::tags( 'th', array( 'colspan' => '2' ), wfMsgExt( 'statistics-header-users', array( 'parseinline' ) ) ) .
@@ -193,7 +193,7 @@
194194 $wgLang->formatNum( $this->activeUsers ),
195195 array( 'class' => 'mw-statistics-users-active' ),
196196 'statistics-users-active-desc',
197 - $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) );
 197+ $wgLang->formatNum( $wgActiveUserDays ) );
198198 }
199199 private function getGroupStats() {
200200 global $wgGroupPermissions, $wgImplicitGroups, $wgLang, $wgUser;

Status & tagging log