r13450 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13449‎ | r13450 | r13451 >
Date:02:54, 4 April 2006
Author:robchurch
Status:old
Tags:
Comment:
* Count log entries too, for uber-anal-completeness' sake
* Fix oversight in counts
Modified paths:
  • /trunk/phase3/maintenance/removeUnusedAccounts.php (modified) (history)
  • /trunk/phase3/maintenance/userFunctions.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/removeUnusedAccounts.php
@@ -34,7 +34,7 @@
3535 echo( "Locating inactive users..." );
3636 foreach( $users as $user ) {
3737 if( $user != 1 ) { # Don't *touch* the first user account, ever
38 - if( CountEdits( $user, false ) == 0 && CountImages( $user, false ) == 0 ) {
 38+ if( CountEdits( $user, false ) == 0 && CountImages( $user, false ) == 0 && CountLogs( $user, false ) == 0 ) {
3939 # User has no edits or images, mark them for deletion
4040 $del[] = $user;
4141 $count++;
Index: trunk/phase3/maintenance/userFunctions.inc
@@ -18,7 +18,7 @@
1919 function CountEdits( $user, $slave = true ) {
2020 $dbw =& wfGetDB( $slave ? DB_SLAVE: DB_MASTER );
2121 # Count current edits
22 - $res = $dbw->select( 'revision', 'COUNT(rev_id) AS count', array( 'rev_user' => $user ) );
 22+ $res = $dbw->select( 'revision', 'COUNT(*) AS count', array( 'rev_user' => $user ) );
2323 $row = $dbw->fetchObject( $res );
2424 $count = $row->count;
2525 # Count deleted edits
@@ -39,7 +39,7 @@
4040 function CountImages( $user, $slave = true ) {
4141 $dbw =& wfGetDB( $slave ? DB_SLAVE: DB_MASTER );
4242 # Count current images
43 - $res = $dbw->select( 'image', 'COUNT(rev_id) AS count', array( 'img_user' => $user ) );
 43+ $res = $dbw->select( 'image', 'COUNT(*) AS count', array( 'img_user' => $user ) );
4444 $row = $dbw->fetchObject( $res );
4545 $count = $row->count;
4646 # Count deleted edits
@@ -51,6 +51,23 @@
5252 }
5353
5454 /**
 55+ * Count the number of log entries associated with the specified user
 56+ *
 57+ * @param integer $user User ID
 58+ * @param bool $slave Whether or not a slave can be used
 59+ * @return integer
 60+ */
 61+function CountLogs( $user, $slave = true ) {
 62+ $dbw =& wfGetDB( $slave ? DB_SLAVE: DB_MASTER );
 63+ # Count log entries
 64+ $res = $dbw->select( 'logging', 'COUNT(*) AS count', array( 'log_user' => $user ) );
 65+ $row = $dbw->fetchObject( $res );
 66+ $count = $row->count;
 67+ # Done
 68+ return( $count );
 69+}
 70+
 71+/**
5572 * Retrieve all valid user IDs
5673 *
5774 * @return array

Status & tagging log