Index: trunk/phase3/maintenance/archives/patch-ss_active_users.sql |
— | — | @@ -1,6 +1,3 @@ |
2 | 2 | -- More statistics, for version 1.14 |
3 | 3 | |
4 | 4 | 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 @@ |
147 | 147 | |
148 | 148 | // 1.14 |
149 | 149 | array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), |
| 150 | + array( 'do_active_users_init' ) |
150 | 151 | ); |
151 | 152 | |
152 | 153 | |
— | — | @@ -1027,6 +1028,23 @@ |
1028 | 1029 | } |
1029 | 1030 | } |
1030 | 1031 | |
| 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 | + |
1031 | 1049 | function purge_cache() { |
1032 | 1050 | global $wgDatabase; |
1033 | 1051 | # We can't guarantee that the user will be able to use TRUNCATE, |
Index: trunk/phase3/includes/SiteStats.php |
— | — | @@ -265,7 +265,7 @@ |
266 | 266 | $dbw->begin(); |
267 | 267 | $dbw->update( 'site_stats', |
268 | 268 | array( 'ss_active_users' => intval($activeUsers) ), |
269 | | - array('1 = 1'), __METHOD__, array( 'LIMIT' => 1 ) |
| 269 | + array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 ) |
270 | 270 | ); |
271 | 271 | $dbw->commit(); |
272 | 272 | } |