r40312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40311‎ | r40312 | r40313 >
Date:19:22, 1 September 2008
Author:aaron
Status:old
Tags:
Comment:
* Remove mysql var and move field init to updaters.inc
Modified paths:
  • /trunk/phase3/includes/SiteStats.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-ss_active_users.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-ss_active_users.sql
@@ -1,6 +1,3 @@
22 -- More statistics, for version 1.14
33
44 ALTER TABLE /*$wgDBprefix*/site_stats ADD ss_active_users bigint default '-1';
5 -SELECT @activeusers := COUNT( DISTINCT rc_user_text ) FROM /*$wgDBprefix*/recentchanges
6 -WHERE rc_user != 0 AND rc_bot = 0 AND rc_log_type != 'newusers';
7 -UPDATE /*$wgDBprefix*/site_stats SET ss_active_users=@activeusers;
Index: trunk/phase3/maintenance/updaters.inc
@@ -146,6 +146,7 @@
147147
148148 // 1.14
149149 array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
 150+ array( 'do_active_users_init' )
150151 );
151152
152153
@@ -1027,6 +1028,23 @@
10281029 }
10291030 }
10301031
 1032+function do_active_users_init() {
 1033+ global $wgDatabase;
 1034+ $activeUsers = $wgDatabase->selectField( 'site_stats', 'ss_active_users',
 1035+ array( 'ss_row_id' => 1 ), __METHOD__ );
 1036+ if( $activeUsers === -1 ) {
 1037+ $activeUsers = $wgDatabase->selectField( 'recentchanges',
 1038+ 'COUNT( DISTINCT rc_user_text )',
 1039+ array( 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ), __METHOD__
 1040+ );
 1041+ $wgDatabase->update( 'site_stats',
 1042+ array( 'ss_active_users' => intval($activeUsers) ),
 1043+ array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
 1044+ );
 1045+ }
 1046+ echo( "...ss_active_users user count set...\n" );
 1047+}
 1048+
10311049 function purge_cache() {
10321050 global $wgDatabase;
10331051 # We can't guarantee that the user will be able to use TRUNCATE,
Index: trunk/phase3/includes/SiteStats.php
@@ -265,7 +265,7 @@
266266 $dbw->begin();
267267 $dbw->update( 'site_stats',
268268 array( 'ss_active_users' => intval($activeUsers) ),
269 - array('1 = 1'), __METHOD__, array( 'LIMIT' => 1 )
 269+ array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
270270 );
271271 $dbw->commit();
272272 }