public function execute() {
$this->output( "Remove unused accounts\n\n" );
-
+
# Do an initial scan for inactive accounts and report the result
$this->output( "Checking for unused user accounts...\n" );
$del = array();
}
$count = count( $del );
$this->output( "...found {$count}.\n" );
-
+
# If required, go back and delete each marked account
if ( $count > 0 && $this->hasOption( 'delete' ) ) {
$this->output( "\nDeleting inactive accounts..." );
}
$this->output( "\n" );
}
-
+
/**
* Could the specified user account be deemed inactive?
* (No edits, no deleted edits, no log entries, no current/old uploads)
*
* @param $id User's ID
- * @param $master Perform checking on the master
+ * @param $master bool Perform checking on the master
* @return bool
*/
private function isInactiveAccount( $id, $master = false ) {
$dbo = wfGetDB( $master ? DB_MASTER : DB_SLAVE );
$checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log',
- 'image' => 'img', 'oldimage' => 'oi' );
+ 'image' => 'img', 'oldimage' => 'oi', 'filearchive' => 'fa' );
$count = 0;
-
- $dbo->begin();
+
+ $dbo->begin( __METHOD__ );
foreach ( $checks as $table => $fprefix ) {
$conds = array( $fprefix . '_user' => $id );
$count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, __METHOD__ );
}
- $dbo->commit();
-
+ $dbo->commit( __METHOD__ );
+
return $count == 0;
}
}
$maintClass = "RemoveUnusedAccounts";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );