4 * Support functions for the removeUnusedAccounts maintenance script
8 * @subpackage Maintenance
9 * @author Rob Church <robchur@gmail.com>
13 * Could the specified user account be deemed inactive?
14 * (No edits, no deleted edits, no log entries, no current/old uploads)
16 * @param $id User's ID
17 * @param $master Perform checking on the master
20 function isInactiveAccount( $id, $master = false ) {
21 $dbo =& wfGetDB( $master ? DB_MASTER : DB_SLAVE );
22 $fname = 'isInactiveAccount';
23 $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log',
24 'image' => 'img', 'oldimage' => 'oi' );
27 $dbo->immediateBegin();
28 foreach( $checks as $table => $fprefix ) {
29 $conds = array( $fprefix . '_user' => $id );
30 $count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, $fname );
32 $dbo->immediateCommit();
38 * Show help for the maintenance script
41 echo( "Delete unused user accounts from the database.\n\n" );
42 echo( "USAGE: php removeUnusedAccounts.php [--delete]\n\n" );
43 echo( " --delete : Delete accounts which are discovered to be inactive\n" );