/** * Find which communities contain revisions from the given users and batch * tasks to revert those revisions * * This task should only run from community.wikia.com, where the UserRollback * extension is enabled. * * @param array $users list of user names or IPs whose revisions should be reverted * @param int $timestamp Unix time after which revisions should be reverted * @param string $queue */ public function enqueueRollback(array $identifiers, $timestamp, $queue) { $affectedWikis = $this->getAffectedWikis($identifiers); $taskLists = []; foreach ($affectedWikis as $wikiId => $usersOnWiki) { $task = new UserRollbackTask(); $taskLists[] = (new AsyncTaskList())->wikiId($wikiId)->setPriority($queue)->add($task->call('doRollback', $usersOnWiki, $timestamp)); } $result = []; if (!empty($taskLists)) { $result = AsyncTaskList::batch($taskLists); } return $result; }
/** * @details Adds UserRollback task into the queue * * @param $request UserRollbackRequest UserRollback task data * @return bool Operation status */ protected function addTask(UserRollbackRequest $request) { $params = $request->getTaskArguments(); $priority = $params['priority'] > 1 ? BatchTask::PRIORITY_HIGH : BatchTask::PRIORITY_LOW; unset($params['priority']); $task = new UserRollbackTask(); $taskId = $task->createTask($params, TASK_QUEUED, $priority); return $taskId > 0; }