private function clearCaches() { foreach ($this->oldCAUsers as $oldCAUser) { $oldCAUser->quickInvalidateCache(); } $this->newCAUser->quickInvalidateCache(); }
/** * There's a race condition of some kind in cache purging (T94491), * so see if the cache still thinks they're being renamed and purge * it if it's wrong * * @param string $name */ function checkCachePurge($name) { $ca = new CentralAuthUser($name); if ($ca->renameInProgress()) { $ca->quickInvalidateCache(); } }
protected function done() { parent::done(); foreach ($this->params['from'] as $from) { $caOld = new CentralAuthUser($from); $caOld->quickInvalidateCache(); } }
/** * 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(); }
<?php $IP = getenv('MW_INSTALL_PATH'); if ($IP === false) { $IP = dirname(__FILE__) . '/../../..'; } require_once "{$IP}/maintenance/commandLine.inc"; echo "Populating global groups table with stewards...\n"; // Fetch local stewards $dbl = wfGetDB(DB_SLAVE); // Get local database $result = $dbl->select(array('user', 'user_groups'), array('user_name'), array('ug_group' => 'steward', 'user_id = ug_user'), 'migrateStewards.php'); $localStewards = array(); foreach ($result as $row) { $localStewards[] = $row->user_name; } echo "Fetched " . count($localStewards) . " from local database... Checking for attached ones\n"; $dbg = CentralAuthUser::getCentralDB(); $globalStewards = array(); $result = $dbg->select(array('globaluser', 'localuser'), array('gu_name', 'gu_id'), array('gu_name = lu_name', 'lu_wiki' => wfWikiId(), 'gu_name IN (' . $dbg->makeList($localStewards) . ')'), 'migrateStewards.php'); foreach ($result as $row) { $globalStewards[$row->gu_name] = $row->gu_id; } echo "Fetched " . count($localStewards) . " SULed stewards... Adding them in group\n"; foreach ($globalStewards as $user => $id) { $dbg->insert('global_user_groups', array('gug_user' => $id, 'gug_group' => 'steward'), 'migrateStewards.php'); echo "Added {$user}\n"; $u = new CentralAuthUser($user); $u->quickInvalidateCache(); // Don't bother regenerating the steward's cache. }
/** * @param $group string */ function invalidateRightsCache($group) { // Figure out all the users in this group. // Use the master over here as this could go horribly wrong with newly created or just renamed groups $dbr = CentralAuthUser::getCentralDB(); $res = $dbr->select(array('global_user_groups', 'globaluser'), 'gu_name', array('gug_group' => $group, 'gu_id=gug_user'), __METHOD__); // Invalidate their rights cache. foreach ($res as $row) { $cu = new CentralAuthUser($row->gu_name); $cu->quickInvalidateCache(); } }
/** * @param $group */ function invalidateRightsCache($group) { // Figure out all the users in this group. $dbr = CentralAuthUser::getCentralDB(); $res = $dbr->select(array('global_user_groups', 'globaluser'), 'gu_name', array('gug_group' => $group, 'gu_id=gug_user'), __METHOD__); // Invalidate their rights cache. foreach ($res as $row) { $cu = new CentralAuthUser($row->gu_name); $cu->quickInvalidateCache(); } }
protected function done() { $this->renameuserStatus->done(wfWikiID()); $caNew = new CentralAuthUser($this->params['to']); $caNew->quickInvalidateCache(); }