-# Count the number of edits the specified user has made
-function CountEdits( $user_id ) {
- # We've *got* to pull this stuff off the master. If the user *has* made an edit, but it hasn't
- # been replicated to the slaves yet, we'll end up falsely marking them as inactive. This could
- # (and usually would) lead to their deletion.
- $dbw =& wfGetDB( DB_MASTER );
- $sql = 'SELECT COUNT(rev_id) AS count FROM ' . $dbw->tableName( 'revision' ) . ' WHERE rev_user = ' . $user_id;
- $res = $dbw->query( $sql );
- $row = $dbw->fetchObject( $res );
- return( $row->count );
-}
+/**
+ * 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
+ * @return bool
+ */
+function isInactiveAccount( $id, $master = false ) {
+ $dbo = wfGetDB( $master ? DB_MASTER : DB_SLAVE );
+ $fname = 'isInactiveAccount';
+ $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log',
+ 'image' => 'img', 'oldimage' => 'oi' );
+ $count = 0;