Пример #1
0
 /**
  * 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;
 }
 /**
  * find which articles depend on this resource being changed
  *
  * @param string $table db table to check. ex: 'imagelinks', 'templatelinks'
  * @return array list of task ids that will purge the dependencies in parsoid
  */
 public function findDependencies($table)
 {
     global $wgCityId;
     $cache = $this->title->getBacklinkCache();
     $batches = $cache->partition($table, 20);
     $taskLists = [];
     foreach ($batches as $batch) {
         list($start, $end) = $batch;
         $task = (new ParsoidCacheUpdateTask())->title($this->title);
         $taskLists[] = (new AsyncTaskList())->setPriority(ParsoidPurgePriorityQueue::NAME)->wikiId($wgCityId)->add($task->call('onDependencyChange', $table, $start, $end));
     }
     $result = [];
     if (!empty($taskLists)) {
         $result = AsyncTaskList::batch($taskLists);
     }
     return $result;
 }
 public static function onCreatePromoteImageReviewTask($type, $list)
 {
     if (empty($list)) {
         return true;
     }
     if (TaskRunner::isModern('PromoteImageReviewTask')) {
         $batch = [];
         foreach ($list as $targetWikiId => $wikis) {
             $taskList = new \Wikia\Tasks\AsyncTaskList();
             $task = new \Wikia\Tasks\Tasks\PromoteImageReviewTask();
             $call = $task->call($type, $targetWikiId, $wikis);
             $taskList->add($call);
             $batch[] = $taskList;
         }
         \Wikia\Tasks\AsyncTaskList::batch($batch);
     } else {
         $task = new PromoteImageReviewTask();
         $key = $type == 'delete' ? 'deletion_list' : 'upload_list';
         $params = [$key => $list];
         $task->createTask($params, TASK_QUEUED);
     }
     return true;
 }
Пример #4
0
 /**
  * queue a set of BaseTask objects
  *
  * @param array $tasks
  * @return array task ids
  */
 public static function batch(array $tasks)
 {
     $taskLists = [];
     foreach ($tasks as $task) {
         /** @var BaseTask $task $taskLists */
         $taskLists = array_merge($taskLists, $task->convertToTaskLists());
     }
     \Wikia\Logger\WikiaLogger::instance()->info('BaseTask::batch', ['count' => count($tasks), 'task' => get_class(reset($tasks)), 'backtrace' => new \Exception()]);
     return AsyncTaskList::batch($taskLists);
 }