Index: trunk/phase3/maintenance/removeUnusedAccounts.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | echo( "Locating inactive users..." ); |
36 | 36 | foreach( $users as $user ) { |
37 | 37 | 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 ) { |
39 | 39 | # User has no edits or images, mark them for deletion |
40 | 40 | $del[] = $user; |
41 | 41 | $count++; |
Index: trunk/phase3/maintenance/userFunctions.inc |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | function CountEdits( $user, $slave = true ) { |
20 | 20 | $dbw =& wfGetDB( $slave ? DB_SLAVE: DB_MASTER ); |
21 | 21 | # 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 ) ); |
23 | 23 | $row = $dbw->fetchObject( $res ); |
24 | 24 | $count = $row->count; |
25 | 25 | # Count deleted edits |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | function CountImages( $user, $slave = true ) { |
41 | 41 | $dbw =& wfGetDB( $slave ? DB_SLAVE: DB_MASTER ); |
42 | 42 | # 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 ) ); |
44 | 44 | $row = $dbw->fetchObject( $res ); |
45 | 45 | $count = $row->count; |
46 | 46 | # Count deleted edits |
— | — | @@ -51,6 +51,23 @@ |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
| 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 | +/** |
55 | 72 | * Retrieve all valid user IDs |
56 | 73 | * |
57 | 74 | * @return array |