public function execute() {
		$userName = '******'; // <- targer username

		$user = new CentralAuthUser( $userName );
		if ( !$user->exists() ) {
			echo "Cannot unsuppress non-existent user {$userName}!\n";
			exit( 0 );
		}
		$userName = $user->getName(); // sanity
		$wikis = $user->listAttached(); // wikis with attached accounts
		foreach ( $wikis as $wiki ) {
			$lb = wfGetLB( $wiki );
			$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
			# Get local ID like $user->localUserData( $wiki ) does
			$localUserId = $dbw->selectField( 'user', 'user_id',
				array( 'user_name' => $userName ), __METHOD__ );

			$delUserBit = Revision::DELETED_USER;
			$hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
				array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
			echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
			# Unsuppress username on edits
			if ( $hiddenCount > 0 ) {
				echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
				IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
				echo "done!\n\n";
			}
			$lb->reuseConnection( $dbw ); // not really needed
			# Don't lag too bad
			wfWaitForSlaves( 5 );
		}
	}
 protected function done()
 {
     parent::done();
     foreach ($this->params['from'] as $from) {
         $caOld = new CentralAuthUser($from);
         $caOld->quickInvalidateCache();
     }
 }
 private function updateUser($username)
 {
     $user = new CentralAuthUser($username);
     $this->output('Resetting user_token for "' . $username . '": ');
     // Change value
     $user->resetAuthToken();
     $this->output(" OK\n");
 }
 function execute($par)
 {
     global $wgMemc;
     $tempToken = $this->getRequest()->getVal('token');
     $logout = $this->getRequest()->getBool('logout');
     # Don't cache error messages
     $this->getOutput()->enableClientCache(false);
     if (strlen($tempToken) == 0) {
         $this->setHeaders();
         $this->getOutput()->addWikiMsg('centralauth-autologin-desc');
         return;
     }
     $key = CentralAuthUser::memcKey('login-token', $tempToken);
     $data = $wgMemc->get($key);
     $wgMemc->delete($key);
     if (!$data) {
         $msg = 'Token is invalid or has expired';
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     $userName = $data['userName'];
     $token = $data['token'];
     $remember = $data['remember'];
     if ($data['wiki'] != wfWikiID()) {
         $msg = 'Bad token (wrong wiki)';
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     $centralUser = new CentralAuthUser($userName);
     $loginResult = $centralUser->authenticateWithToken($token);
     if ($loginResult != 'ok') {
         $msg = "Bad token: {$loginResult}";
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     // Auth OK.
     if ($logout) {
         $centralUser->deleteGlobalCookies();
     } else {
         $centralUser->setGlobalCookies($remember);
     }
     $this->getOutput()->disable();
     wfResetOutputBuffers();
     header('Cache-Control: no-cache');
     header('Content-Type: image/png');
     global $wgCentralAuthLoginIcon;
     if ($wgCentralAuthLoginIcon) {
         readfile($wgCentralAuthLoginIcon);
     } else {
         readfile(dirname(__FILE__) . '/1x1.png');
     }
 }
 public function execute()
 {
     $params = $this->extractRequestParams();
     $prop = array_flip((array) $params['prop']);
     $from = isset($params['from']) ? $params['from'] : null;
     $APIResult = $this->getResult();
     $data = array();
     /**
      * @var $wikiSet WikiSet
      */
     foreach (WikiSet::getAllWikiSets($from, $params['limit'], $params['orderbyname']) as $wikiSet) {
         $entry = array();
         $entry['id'] = $wikiSet->getId();
         $entry['name'] = $wikiSet->getName();
         if (isset($prop['type'])) {
             $entry['type'] = $wikiSet->getType();
         }
         if (isset($prop['wikisincluded'])) {
             $entry['wikisincluded'] = $wikiSet->getWikis();
             if (count($entry['wikisincluded'])) {
                 $APIResult->setIndexedTagName($entry['wikisincluded'], 'wiki');
             }
         }
         if (isset($prop['wikisnotincluded'])) {
             $entry['wikisnotincluded'] = array_diff(CentralAuthUser::getWikiList(), $wikiSet->getWikis());
             if (count($entry['wikisnotincluded'])) {
                 $APIResult->setIndexedTagName($entry['wikisnotincluded'], 'wiki');
             }
         }
         $data[] = $entry;
     }
     $APIResult->setIndexedTagName($data, 'wikiset');
     $APIResult->addValue('query', $this->getModuleName(), $data);
 }
 /**
  * Try to create and attach the user.
  * @throws Exception
  * @return bool Success
  */
 public function run()
 {
     $username = $this->params['name'];
     $from = $this->params['from'];
     $wiki = wfWikiID();
     if (isset($this->params['session'])) {
         // restore IP and other request data
         $this->params['session']['userId'] = 0;
         $this->params['session']['sessionId'] = '';
         $callback = RequestContext::importScopedSession($this->params['session']);
     }
     $user = User::newFromName($username);
     $centralUser = CentralAuthUser::getInstance($user);
     if ($user->getId() !== 0) {
         wfDebugLog('CentralAuth', __CLASS__ . ": tried to create local account for {$username} " . "on {$wiki} from {$from} but one already exists\n");
         return true;
     } elseif (!$centralUser->exists()) {
         wfDebugLog('CentralAuth', __CLASS__ . ": tried to create local account for {$username} " . "on {$wiki} from {$from} but no global account exists\n");
         return true;
     } elseif ($centralUser->attachedOn($wiki)) {
         wfDebugLog('CentralAuth', __CLASS__ . ": tried to create local account for {$username} " . "on {$wiki} from {$from} but an attached local account already exists\n");
         return true;
     }
     $success = CentralAuthHooks::attemptAddUser($user);
     if ($success) {
         $centralUser->invalidateCache();
     }
     return true;
 }
 /**
  * Check that we can perform the rename
  *
  * @param User $oldUser
  * @param User $newUser
  *
  * @return Status
  */
 public function validate(User $oldUser, User $newUser)
 {
     $status = new Status();
     if (!User::isCreatableName($newUser->getName())) {
         $status->fatal('centralauth-rename-badusername');
     }
     $caOldUser = CentralAuthUser::getInstance($oldUser);
     if (!$caOldUser->exists()) {
         $status->fatal('centralauth-rename-doesnotexist');
     }
     $caNewUser = CentralAuthUser::getInstance($newUser);
     if ($caNewUser->exists()) {
         $status->fatal('centralauth-rename-alreadyexists');
     }
     $unattached = $caNewUser->listUnattached();
     if ($unattached) {
         $status->fatal('centralauth-rename-unattached-intheway');
     }
     // Check we're not currently renaming the user
     $renameState = $caOldUser->renameInProgress();
     if ($renameState) {
         $status->fatal('centralauth-rename-alreadyinprogress', $renameState[1]);
     }
     return $status;
 }
 public function execute()
 {
     $user = $this->getUser();
     $params = $this->extractRequestParams();
     // If we're in JSON callback mode, no tokens can be obtained
     if ($this->lacksSameOriginSecurity()) {
         $this->dieUsage('Cannot obtain a centralauthtoken when using a callback', 'hascallback');
     }
     if ($user->isAnon()) {
         $this->dieUsage('Anonymous users cannot obtain a centralauthtoken', 'notloggedin');
     }
     if (CentralAuthHooks::hasApiToken()) {
         $this->dieUsage('Cannot obtain a centralauthtoken when using centralauthtoken', 'norecursion');
     }
     $centralUser = CentralAuthUser::getInstance($user);
     if (!$centralUser->exists() || !$centralUser->isAttached()) {
         $this->dieUsage('Cannot obtain a centralauthtoken without an attached global account', 'notattached');
     }
     $data = array('userName' => $user->getName(), 'token' => $centralUser->getAuthToken());
     global $wgMemc;
     $loginToken = MWCryptRand::generateHex(32) . dechex($centralUser->getId());
     $key = CentralAuthUser::memcKey('api-token', $loginToken);
     $wgMemc->add($key, $data, 60);
     $this->getResult()->addValue(null, $this->getModuleName(), array('centralauthtoken' => $loginToken));
 }
/**
 * Copy user data for this wiki into the localuser table
 */
function migratePassZero()
{
    global $wgDBname;
    $dbr = wfGetDB(DB_SLAVE);
    $chunkSize = 1000;
    $start = microtime(true);
    $migrated = 0;
    $users = array();
    // List all user accounts on this wiki in the migration table
    // on the central authentication server.
    $lastUser = $dbr->selectField('user', 'MAX(user_id)', '', __FUNCTION__);
    for ($min = 0; $min <= $lastUser; $min += $chunkSize) {
        $max = $min + $chunkSize - 1;
        $result = $dbr->select('user', array('user_id', 'user_name'), "user_id BETWEEN {$min} AND {$max}", __FUNCTION__);
        foreach ($result as $row) {
            $users[intval($row->user_id)] = $row->user_name;
            ++$migrated;
        }
        CentralAuthUser::storeMigrationData($wgDBname, $users);
        $users = array();
        // clear the array for the next pass
        $delta = microtime(true) - $start;
        $rate = $delta == 0.0 ? 0.0 : $migrated / $delta;
        printf("%s %d (%0.1f%%) done in %0.1f secs (%0.3f accounts/sec).\n", $wgDBname, $migrated, min($max, $lastUser) / $lastUser * 100.0, $delta, $rate);
        if (($min + $chunkSize) % ($chunkSize * 10) == 0) {
            echo "Waiting for slaves to catch up ... ";
            CentralAuthUser::waitForSlaves();
            echo "done\n";
        }
    }
}
 public function execute()
 {
     $params = $this->extractRequestParams();
     $prop = array_flip((array) $params['prop']);
     $APIResult = $this->getResult();
     $data = array();
     $dbr = CentralAuthUser::getCentralSlaveDB();
     $fields = array('ggp_group');
     if (isset($prop['rights'])) {
         $fields[] = 'ggp_permission';
     }
     $result = $dbr->select('global_group_permissions', $fields, array(), __METHOD__, array('DISTINCT'));
     $globalGroups = array();
     foreach ($result as $row) {
         if (!isset($globalGroups[$row->ggp_group])) {
             $globalGroups[$row->ggp_group] = array('rights' => array());
         }
         if (isset($prop['rights'])) {
             $globalGroups[$row->ggp_group]['rights'][] = $row->ggp_permission;
         }
     }
     foreach ($globalGroups as $name => $value) {
         $entry = array('name' => $name);
         if (isset($prop['rights']) && count($value['rights'])) {
             $entry['rights'] = $value['rights'];
             $APIResult->setIndexedTagName($entry['rights'], 'right');
         }
         $data[] = $entry;
     }
     $APIResult->setIndexedTagName($data, 'globalgroup');
     $APIResult->addValue('query', $this->getModuleName(), $data);
 }
 public function execute()
 {
     if (!class_exists('CentralAuthUser')) {
         $this->error("CentralAuth isn't enabled on this wiki\n", 1);
     }
     $username = $this->getArg(0);
     $user = User::newFromName($username);
     if ($user === false) {
         $this->error("'{$username}' is an invalid username\n", 1);
     }
     // Normalize username
     $username = $user->getName();
     if ($user->getId()) {
         $this->error("User '{$username}' already exists\n", 1);
     } else {
         global $wgAuth;
         $central = CentralAuthUser::getInstance($user);
         if (!$central->exists()) {
             $this->error("No such global user: '******'\n", 1);
         }
         $user->loadDefaults($username);
         $user->addToDatabase();
         $wgAuth->initUser($user, true);
         $wgAuth->updateUser($user);
         # Notify hooks (e.g. Newuserlog)
         Hooks::run('AuthPluginAutoCreate', array($user));
         # Update user count
         $ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
         $ssUpdate->doUpdate();
         $this->output("User '{$username}' created\n");
     }
 }
 /**
  * Execute the job
  *
  * @return bool
  */
 public function run()
 {
     $username = $this->params['username'];
     $by = $this->params['by'];
     $wikis = $this->params['wikis'];
     $suppress = $this->params['suppress'];
     $reason = $this->params['reason'];
     $user = new CentralAuthUser($username);
     if (!$user->exists()) {
         wfDebugLog('suppressjob', "Requested to suppress non-existent user {$username} by {$by}.");
     }
     foreach ($wikis as $wiki) {
         $user->doLocalSuppression($suppress, $wiki, $by, $reason);
         wfDebugLog('suppressjob', ($suppress ? 'S' : 'Uns') . "uppressed {$username} at {$wiki} by {$by} via job queue.");
     }
     return true;
 }
 /**
  * Switches a user's preferences off
  * @param $user User object to set preferences for
  * @param $global bool Whether to apply this change on all wikis in $wgPrefSwitchWikis
  */
 public static function switchOff($user, $global = false)
 {
     self::switchOffUser($user);
     if ($global) {
         $globalUser = new CentralAuthUser($user->getName());
         if (!$globalUser->exists()) {
             return;
         }
         $accounts = $globalUser->queryAttached();
         foreach ($accounts as $account) {
             $remoteUser = UserRightsProxy::newFromName($account['wiki'], $globalUser->getName(), true);
             if ($remoteUser) {
                 self::switchOffUser($remoteUser);
             }
         }
     }
 }
 /**
  * Get a DatabaseBase object for the CentralAuth db
  *
  * @param int $type DB_SLAVE or DB_MASTER
  *
  * @return DatabaseBase
  */
 protected function getDB($type = DB_SLAVE)
 {
     if ($type === DB_MASTER) {
         return CentralAuthUser::getCentralDB();
     } else {
         return CentralAuthUser::getCentralSlaveDB();
     }
 }
 /**
  * @param $row
  */
 function setCurrent($row)
 {
     parent::setCurrent($row);
     if ($row !== false) {
         $caRow = isset($this->globalData[$row->user_name]) ? $this->globalData[$row->user_name] : false;
         $this->current->centralAuthObj = CentralAuthUser::newFromRow($caRow);
     }
 }
 public function execute()
 {
     $centralMaster = CentralAuthUser::getCentralDB();
     $centralSlave = CentralAuthUser::getCentralSlaveDB();
     if ($this->getOption('delete', false) === true) {
         $this->dryrun = false;
     }
     $wiki = $this->getOption('wiki', false);
     if ($wiki !== false) {
         $this->wiki = $wiki;
     }
     if ($this->getOption('verbose', false) !== false) {
         $this->verbose = true;
     }
     // since the keys on localnames are not conducive to batch operations and
     // because of the database shards, grab a list of the wikis and we will
     // iterate from there
     $wikis = array();
     if (!is_null($this->wiki)) {
         $wikis[] = $this->wiki;
     } else {
         $result = $centralSlave->select('localnames', array('ln_wiki'), "", __METHOD__, array("DISTINCT", "ORDER BY" => "ln_wiki ASC"));
         foreach ($result as $row) {
             $wikis[] = $row->ln_wiki;
         }
     }
     // iterate through the wikis
     foreach ($wikis as $wiki) {
         $localdb = wfGetDB(DB_SLAVE, array(), $wiki);
         $lastUsername = "";
         $this->output("Checking localnames for {$wiki} ...\n");
         // batch query localnames from the wiki
         do {
             $this->output("\t ... querying from '{$lastUsername}'\n");
             $result = $centralSlave->select('localnames', array('ln_name'), array("ln_wiki" => $wiki, "ln_name > " . $centralSlave->addQuotes($lastUsername)), __METHOD__, array("LIMIT" => $this->batchSize, "ORDER BY" => "ln_name ASC"));
             // iterate through each of the localnames to confirm that a local user
             foreach ($result as $u) {
                 $localUser = $localdb->select('user', array('user_name'), array("user_name" => $u->ln_name), __METHOD__);
                 // check to see if the user did not exist in the local user table
                 if ($localUser->numRows() == 0) {
                     if ($this->verbose) {
                         $this->output("Local user not found for localname entry {$u->ln_name}@{$wiki}\n");
                     }
                     $this->total++;
                     if (!$this->dryrun) {
                         // go ahead and delete the extraneous entry
                         $deleted = $centralMaster->delete('localnames', array("ln_wiki" => $wiki, "ln_name" => $u->ln_name), __METHOD__);
                         // TODO: is there anyway to check the success of the delete?
                         $this->deleted++;
                     }
                 }
                 $lastUsername = $u->ln_name;
             }
         } while ($result->numRows() > 0);
     }
     $this->report();
     $this->output("done.\n");
 }
 /**
  *
  */
 function showLogExtract()
 {
     $user = $this->mGlobalUser->getName();
     $text = '';
     $numRows = LogEventsList::showLogExtract($text, array('globalauth', 'suppress'), Title::newFromText("User:{$user}@global")->getPrefixedText(), '', array('showIfEmpty' => true));
     if ($numRows) {
         $this->getOutput()->addHTML(Xml::fieldset(wfMsg('centralauth-admin-logsnippet'), $text));
     }
 }
 public function provideAbortLogin()
 {
     $user = User::newFromName('GlobalUser');
     $lockedUser = User::newFromName('GlobalLockedUser');
     // We can fake out CentralAuthUser::getInstance() by adding centralAuthObj
     $noUser = User::newFromName('NoUser');
     $noUser->centralAuthObj = CentralAuthUser::newUnattached('NoUser');
     return array(array($user, true, 'Attached user can login'), array($noUser, true, 'Unattached user can login'), array($lockedUser, false, 'Locked User cannot login'));
 }
 public function execute()
 {
     $this->output("CentralAuth migration pass 1:\n");
     $this->output("Finding accounts which can be migrated without interaction...\n");
     $dbBackground = CentralAuthUser::getCentralSlaveDB();
     $result = $dbBackground->select('globalnames', array('gn_name'), array(), __METHOD__);
     foreach ($result as $row) {
         $this->fromPrefix = $row->gn_name;
         $central = new CentralAuthUser($row->gn_name);
         if ($central->storeAndMigrate()) {
             $this->migrated++;
         }
         if (++$this->total % 1000 == 0) {
             $this->migratePassOneReport();
         }
     }
     $this->migratePassOneReport();
     $this->output("done.\n");
 }
function migratePassOne()
{
    $migrated = 0;
    $total = 0;
    $chunkSize = 1000;
    $start = microtime(true);
    $dbBackground = CentralAuthUser::getCentralSlaveDB();
    $result = $dbBackground->select('globalnames', array('gn_name'), '', __METHOD__);
    foreach ($result as $row) {
        $name = $row->gn_name;
        $central = new CentralAuthUser($name);
        if ($central->storeAndMigrate()) {
            $migrated++;
        }
        if (++$total % $chunkSize == 0) {
            migratePassOneReport($migrated, $total, $start);
        }
    }
    migratePassOneReport($migrated, $total, $start);
    echo "DONE\n";
}
 public function execute()
 {
     $db = CentralAuthUser::getCentralSlaveDB();
     $conds = array();
     $count = 0;
     do {
         $result = $db->select('globaluser', array('gu_name'), array_merge($conds, array('gu_home_db IS NULL OR gu_home_db = ""')), __METHOD__, array('LIMIT' => $this->mBatchSize, 'ORDER BY' => 'gu_name'));
         foreach ($result as $row) {
             $central = new CentralAuthUser($row->gu_name);
             $central->mStateDirty = true;
             $central->saveSettings();
             $count++;
         }
         $this->output("{$count}\n");
         CentralAuthUser::waitForSlaves();
         if ($result->numRows() < $this->mBatchSize) {
             break;
         }
         $conds = array('gu_name > ' . $db->addQuotes($row->gu_name));
     } while (true);
     $this->output("done.\n");
 }
 /**
  * Get a GlobalUser object from a user's global id
  *
  * @param int $id
  * @return GlobalUser
  */
 public static function newFromId($id)
 {
     // Use CentralAuth if available. Use local user to ease testing.
     if (class_exists('\\CentralAuthUser')) {
         $user = \CentralAuthUser::newFromId($id);
     } else {
         $user = \User::newFromId($id);
     }
     if ($user === null) {
         throw new \MWException("Unable to find global user for");
     }
     return new GlobalUser($user);
 }
 public function execute()
 {
     $dbw = CentralAuthUser::getCentralDB();
     $databaseUpdates = new UsersToRenameDatabaseUpdates($dbw);
     // CentralAuthUser::chooseHomeWiki is expensive and called
     // multiple times, so lets cache it.
     $cache = new MapCacheLRU($this->mBatchSize);
     do {
         $rows = $this->doQuery();
         $insertRows = array();
         foreach ($rows as $row) {
             $this->lName = $row->name;
             $this->lWiki = $row->wiki;
             if ($cache->has($row->name)) {
                 $attachableWikis = $cache->get($row->name);
             } else {
                 $ca = new CentralAuthUser($row->name);
                 $attachableWikis = array();
                 $unattached = $ca->queryUnattached();
                 if ($ca->exists()) {
                     $home = $ca->getHomeWiki();
                     $attachableWikis[] = $home;
                     foreach ($unattached as $wiki => $info) {
                         if ($ca->getEmailAuthenticationTimestamp() && $info['email'] === $ca->getEmail() && !is_null($info['emailAuthenticated'])) {
                             $attachableWikis[] = $wiki;
                         }
                     }
                 } else {
                     $home = $ca->chooseHomeWiki($unattached);
                     $attachableWikis[] = $home;
                     if ($unattached[$home]['email'] && isset($unattached[$home]['emailAuthenticated'])) {
                         foreach ($unattached as $wiki => $info) {
                             if ($wiki !== $home && $unattached[$home]['email'] === $info['email'] && isset($info['emailAuthenticated'])) {
                                 $attachableWikis[] = $wiki;
                             }
                         }
                     }
                 }
                 $cache->set($row->name, $attachableWikis);
             }
             if (!in_array($row->wiki, $attachableWikis)) {
                 // Unattached account which is not attachable,
                 // so they're getting renamed :(
                 $this->output("{$row->name}@{$row->wiki} is going to be renamed.\n");
                 $insertRows[] = (array) $row;
             }
         }
         $databaseUpdates->batchInsert($insertRows);
         $count = $dbw->affectedRows();
         $this->output("Inserted {$count} users who we will rename\n");
         $this->output("Waiting for slaves...\n");
         CentralAuthUser::waitForSlaves();
     } while ($count !== 0);
 }
 private function showLogExtract()
 {
     $user = $this->mGlobalUser->getName();
     $text = '';
     $logTypes = array('globalauth');
     if ($this->mCanOversight) {
         $logTypes[] = 'suppress';
     }
     $numRows = LogEventsList::showLogExtract($text, $logTypes, Title::newFromText(MWNamespace::getCanonicalName(NS_USER) . ":{$user}@global")->getPrefixedText(), '', array('showIfEmpty' => true));
     if ($numRows) {
         $this->getOutput()->addHTML(Xml::fieldset($this->msg('centralauth-admin-logsnippet')->text(), $text));
     }
 }
 /**
  * Set the cookie for hiding fundraising banners.
  */
 function setHideCookie()
 {
     global $wgNoticeCookieDomain, $wgCookieSecure, $wgNoticeHideBannersExpiration;
     if (is_numeric($wgNoticeHideBannersExpiration)) {
         $exp = $wgNoticeHideBannersExpiration;
     } else {
         $exp = time() + 86400 * 14;
         // Cookie expires after 2 weeks
     }
     if (is_callable(array('CentralAuthUser', 'getCookieDomain'))) {
         $cookieDomain = CentralAuthUser::getCookieDomain();
     } else {
         $cookieDomain = $wgNoticeCookieDomain;
     }
     // Hide fundraising banners for this domain
     setcookie('centralnotice_fundraising', 'hide', $exp, '/', $cookieDomain, $wgCookieSecure);
 }
 /**
  * @param $row
  */
 function setCurrent($row)
 {
     parent::setCurrent($row);
     if ($row !== false) {
         if (isset($this->globalData[$row->user_name])) {
             $caRow = $this->globalData[$row->user_name];
             // Like taken from GlobalRenameUserStatus::getNames
             $renameUser = array();
             if ($caRow->ru_oldname) {
                 $renameUser = array($caRow->ru_oldname, $caRow->ru_newname);
             }
             $this->current->centralAuthObj = CentralAuthUser::newFromRow($caRow, $renameUser);
         } else {
             $this->current->centralAuthObj = CentralAuthUser::newUnattached($row->user_name);
         }
     }
 }
 function execute()
 {
     $wikis = file('/srv/mediawiki/dblist/deleted.dblist');
     if ($wikis === false) {
         $this->error('Unable to open deleted.dblist', 1);
     }
     $dbw = $this->getDB(DB_MASTER);
     $cadbw = CentralAuthUser::getCentralDB();
     foreach ($wikis as $wiki) {
         $wiki = rtrim($wiki);
         $this->output("{$wiki}:\n");
         $this->doDeletes($cadbw, 'localnames', 'ln_wiki', $wiki);
         $this->doDeletes($cadbw, 'localuser', 'lu_wiki', $wiki);
         // @todo: Delete from wikisets
     }
     $this->output("Done.\n");
 }
 public function execute()
 {
     $dbw = CentralAuthUser::getCentralDB();
     $dbr = CentralAuthUser::getCentralSlaveDB();
     $total = 0;
     do {
         $rows = $dbr->select(array('users_to_rename', 'localuser'), array('utr_id', 'utr_name', 'utr_wiki'), array(), __METHOD__, array('LIMIT' => $this->mBatchSize), array('localuser' => array('INNER JOIN', 'utr_wiki=lu_wiki AND utr_name=lu_name')));
         $ids = array();
         foreach ($rows as $row) {
             $ids[] = $row->utr_id;
             $this->output("{$row->utr_name}@{$row->utr_wiki} is now attached!\n");
         }
         if ($ids) {
             $count = count($ids);
             $this->output("Deleting {$count} users...\n");
             $dbw->delete('users_to_rename', array('utr_id' => $ids), __METHOD__);
             $total += $count;
         }
         CentralAuthUser::waitForSlaves();
     } while ($rows->numRows() >= $this->mBatchSize);
     $this->output("Removed {$total} users in total.\n");
 }
 /**
  * Rename a global user (this assumes that the data has been verified before
  * and that $newUser is being a creatable user)!
  *
  * @param $options array
  * @return Status
  */
 public function rename(array $options)
 {
     $wikis = $this->oldCAUser->listAttached();
     $status = $this->setRenameStatuses($wikis);
     if (!$status->isOK()) {
         return $status;
     }
     $this->databaseUpdates->update($this->oldUser->getName(), $this->newUser->getName());
     // Update CA's AntiSpoof if enabled
     if (class_exists('CentralAuthSpoofUser')) {
         $spoof = new CentralAuthSpoofUser($this->newUser->getName());
         $spoof->update($this->oldUser->getName());
     }
     // From this point on all code using CentralAuthUser
     // needs to use the new username, except for
     // the renameInProgress function. Probably.
     // Clear some caches...
     $this->oldCAUser->quickInvalidateCache();
     $this->newCAUser->quickInvalidateCache();
     $this->injectLocalRenameUserJobs($wikis, $options);
     $this->logger->log($this->oldUser->getName(), $this->newUser->getName(), $options['reason']);
     return Status::newGood();
 }
 public function execute()
 {
     if (!$this->getUser()->isAllowed('centralauth-unmerge')) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $globalUser = new CentralAuthUser($params['user']);
     if (!$globalUser->exists()) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     } elseif ($globalUser->isOversighted() && !$this->getUser()->isAllowed('centralauth-oversight')) {
         $this->dieUsageMsg(array('nosuchuser', $globalUser->getName()));
     }
     $status = $globalUser->adminDelete($params['reason']);
     if ($status->isGood()) {
         $this->getResult()->addValue(null, $this->getModuleName(), array('user' => $globalUser->getName(), 'reason' => $params['reason']));
     } else {
         if (is_callable(array($this, 'getErrorFormatter'))) {
             $error = $this->getErrorFormatter()->arrayFromStatus($status);
         } else {
             $error = $this->getResult()->convertStatusToArray($status);
         }
         $this->getResult()->addValue('error', null, $error);
     }
 }