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