/**
  * Check that the local user object is part of a global account, and the account is
  * attached on this wiki, and the central OAuth wiki, so we know that the same username
  * on both wikis references the same user. Set the user object to false if they are not.
  * @param int $userId the central OAuth wiki user_id for this username
  * @param string $wgMWOAuthCentralWiki
  * @param User &$user the loca user object
  * @param string $wgMWOAuthSharedUserSource the authoritative extension
  */
 public static function onOAuthGetLocalUserFromCentralId($userId, $wgMWOAuthCentralWiki, &$user, $wgMWOAuthSharedUserSource)
 {
     if ($wgMWOAuthSharedUserSource !== 'CentralAuth') {
         // We aren't supposed to handle this
         return true;
     }
     $dbr = CentralAuthUser::getCentralSlaveDB();
     $user_name = $dbr->selectField('globaluser', 'gu_name', array('gu_id' => $userId), __METHOD__);
     if ($user_name === false) {
         wfDebugLog('CentralAuth', __METHOD__ . ": invalid userId ({$userId}) passed to CentralAuth by OAuth");
         $user = false;
         return false;
     }
     $centralUser = new CentralAuthUser($user_name);
     if ($centralUser->isLocked() || !$centralUser->isAttached() || !$centralUser->attachedOn($wgMWOAuthCentralWiki)) {
         wfDebugLog('CentralAuth', __METHOD__ . ": user '{$user_name}' cannot use OAuth on " . wfWikiID());
         $user = false;
         return false;
     }
     $user = User::newFromName($user_name);
     // One last sanity check
     if ($user->getId() == 0) {
         throw new Exception("Attached user couldn't be loaded from name");
     }
     return true;
 }
 /**
  * @param string $wiki
  * @param DatabaseBase $dbw
  * @return stdClass[]
  */
 protected function findUsers($wiki, DatabaseBase $dbw)
 {
     $rowsToRename = array();
     $updates = new UsersToRenameDatabaseUpdates($dbw);
     $rows = $updates->findUsers($wiki, UsersToRenameDatabaseUpdates::NOTIFIED, $this->mBatchSize);
     foreach ($rows as $row) {
         $user = User::newFromName($row->utr_name);
         $caUser = new CentralAuthUser($row->utr_name);
         if (!$user->getId()) {
             $this->log("'{$row->utr_name}' has been renamed since the last was list generated.");
             $updates->remove($row->utr_name, $row->utr_wiki);
         } elseif ($caUser->attachedOn($row->utr_wiki)) {
             $this->log("'{$row->utr_name}' has become attached to a global account since the list as last generated.");
             $updates->remove($row->utr_name, $row->utr_wiki);
         } elseif (!User::isUsableName($row->utr_name)) {
             // Reserved for a system account, ignore
             $this->log("'{$row->utr_name}' is a reserved username, skipping.");
             $updates->remove($row->utr_name, $row->utr_wiki);
         } else {
             $rowsToRename[] = $row;
         }
     }
     return $rowsToRename;
 }
 /**
  * @param $wiki string
  * @return Bool
  */
 function attachedOn($wiki)
 {
     return $this->mGlobalUser->attachedOn($wiki);
 }