function process($username) { $central = new CentralAuthUser($username); if (!$central->exists()) { $this->output("ERROR: [{$username}] Central account does not exist. So how'd we find it?\n"); return; } try { $unattached = $central->queryUnattached(); } catch (Exception $e) { // This might happen due to localnames inconsistencies (bug 67350) $this->output("ERROR: [{$username}] Fetching unattached accounts failed.\n"); return; } foreach ($unattached as $wiki => $local) { if ($local['email'] === '' && $local['password'] === '') { $this->output("SKIP: [{$username}] Account on {$wiki} has no password or email\n"); return; } } if ($this->fix) { $reason = wfMessage('centralauth-delete-empty-account')->inContentLanguage()->text(); $status = $central->adminDelete($reason); if (!$status->isGood()) { $msg = $status->errors[0]['message']; if ($msg instanceof Message) { $msg = $msg->getKey(); } $this->output("ERROR: [{$username}] Delete failed ({$msg})\n"); return; } $this->output("DELETE: [{$username}] Deleted\n"); } else { $this->output("DELETE: [{$username}] Would delete\n"); } if (count($unattached) !== 0 && $this->migrate) { if ($this->fix) { $central = CentralAuthUser::newUnattached($username, true); if ($central->storeAndMigrate(array(), !$this->suppressRC, $this->safe)) { $unattachedAfter = count($central->queryUnattached()); $this->output("MIGRATE: [{$username}] Success; {$unattachedAfter} left unattached\n"); } else { $this->output("MIGRATE: [{$username}] Fail\n"); } } else { $this->output("MIGRATE: [{$username}] Would attempt\n"); } } }
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); } }