/**
  * Constructor
  *
  * @param $old string The old username
  * @param $new string The new username
  * @param $uid
  * @param $options Array of options
  *	'checkIfUserExists' - bool, whether to update the user table
  */
 function __construct($old, $new, $uid, $options = array())
 {
     $this->old = $old;
     $this->new = $new;
     $this->uid = $uid;
     $this->checkIfUserExists = true;
     if (isset($options['checkIfUserExists'])) {
         $this->checkIfUserExists = $options['checkIfUserExists'];
     }
     $this->tables = array();
     // Immediate updates
     $this->tables['image'] = array('img_user_text', 'img_user');
     $this->tables['oldimage'] = array('oi_user_text', 'oi_user');
     $this->tables['filearchive'] = array('fa_user_text', 'fa_user');
     $this->tablesJob = array();
     // Slow updates
     // If this user has a large number of edits, use the jobqueue
     if (User::newFromId($uid)->getEditCount() > RENAMEUSER_CONTRIBJOB) {
         $this->tablesJob['revision'] = array('rev_user_text', 'rev_user', 'rev_timestamp');
         $this->tablesJob['archive'] = array('ar_user_text', 'ar_user', 'ar_timestamp');
         $this->tablesJob['logging'] = array('log_user_text', 'log_user', 'log_timestamp');
     } else {
         $this->tables['revision'] = array('rev_user_text', 'rev_user');
         $this->tables['archive'] = array('ar_user_text', 'ar_user');
         $this->tables['logging'] = array('log_user_text', 'log_user');
     }
     // Recent changes is pretty hot, deadlocks occur if done all at once
     if (wfQueriesMustScale()) {
         $this->tablesJob['recentchanges'] = array('rc_user_text', 'rc_user', 'rc_timestamp');
     } else {
         $this->tables['recentchanges'] = array('rc_user_text', 'rc_user');
     }
     wfRunHooks('RenameUserSQL', array($this));
 }
 /**
  * Constructor
  *
  * @param string $old The old username
  * @param string $new The new username
  */
 function RenameuserSQL($old, $new, $uid)
 {
     $this->old = $old;
     $this->new = $new;
     $this->uid = $uid;
     $this->tables = array();
     // Immediate updates
     $this->tables['image'] = 'img_user_text';
     $this->tables['oldimage'] = 'oi_user_text';
     # FIXME: $this->tables['filearchive'] = 'fa_user_text'; (not indexed yet)
     $this->tablesJob = array();
     // Slow updates
     // If this user has a large number of edits, use the jobqueue
     if (User::edits($this->uid) > RENAMEUSER_CONTRIBJOB) {
         $this->tablesJob['revision'] = array('rev_user_text', 'rev_user', 'rev_timestamp');
         $this->tablesJob['archive'] = array('ar_user_text', 'ar_user', 'ar_timestamp');
     } else {
         $this->tables['revision'] = 'rev_user_text';
         $this->tables['archive'] = 'ar_user_text';
     }
     // Recent changes is pretty hot, deadlocks occur if done all at once
     if (wfQueriesMustScale()) {
         $this->tablesJob['recentchanges'] = array('rc_user_text', 'rc_user', 'rc_timestamp');
     } else {
         $this->tables['recentchanges'] = 'rc_user_text';
     }
 }
 /**
  * There may be many pages, most of which are reviewed
  */
 public static function generalQueryOK()
 {
     $namespaces = FlaggedRevs::getReviewNamespaces();
     if (!$namespaces || !wfQueriesMustScale()) {
         return true;
     }
     # Get est. of fraction of pages that are reviewed
     $dbr = wfGetDB(DB_SLAVE);
     $reviewedpages = $dbr->estimateRowCount('flaggedpages', '*', array(), __METHOD__);
     $pages = $dbr->estimateRowCount('page', '*', array('page_namespace' => $namespaces), __METHOD__);
     $ratio = $pages / ($pages - $reviewedpages);
     # If dist. is equal, # of rows scanned = $ratio * LIMIT (or until list runs out)
     return $ratio <= 400;
 }