protected function createUploadTask($taskAdditionList) { if (!empty($taskAdditionList)) { $task = new PromoteImageReviewTask(); $task->createTask(array('upload_list' => $taskAdditionList), TASK_QUEUED); } }
public function execute() { $wikis = $this->getWikisToFix(); $corporateModel = new WikiaCorporateModel(); foreach ($wikis as $wiki) { $wikiLocalImage = $this->getCVImage($wiki['city_id']); if (!empty($wikiLocalImage)) { try { $corpWikiId = $corporateModel->getCorporateWikiIdByLang($wiki['city_lang_code']); } catch (Exception $e) { var_dump($wiki['city_id'], $wiki['city_lang_code']); } $t = GlobalTitle::newFromText('Wikia-Visualization-Main.png', NS_FILE, $wiki['city_id']); if (TaskRunner::isModern('PromoteImageReviewTask')) { $task = new \Wikia\Tasks\Tasks\PromoteImageReviewTask(); } else { $task = new PromoteImageReviewTask(); } var_dump($t->getArticleID(), $wiki['city_main_image'], $corpWikiId, $wiki['city_id']); $res = $task->uploadSingleImage($t->getArticleID(), 'Wikia-Visualization-Main.png', $corpWikiId, $wiki['city_id']); if ($res['status'] == 0 && !empty($res['name'])) { var_dump($res); $this->updateVisualizationMainImageName($wiki['city_id'], $res['name']); } } } }
protected function uploadImagesOnWikis() { global $wgCityId; wfProfileIn(__METHOD__); if( !$this->options->skipUpload && $this->options->addImageUploadTask ) { $taskAdditionList = array(); foreach($this->okuploads['main-images'] as $image) { $targetWikiId = $image['city_id']; $targetWikiDbName = WikiFactory::IDtoDB($targetWikiId); $image['name'] = str_replace(',' . $targetWikiDbName, '', $image['name']); $taskAdditionList[$targetWikiId][$wgCityId][] = $image; } foreach($this->okuploads['slider-images'] as $image) { $targetWikiId = $image['city_id']; $targetWikiDbName = WikiFactory::IDtoDB($targetWikiId); $image['name'] = str_replace(',' . $targetWikiDbName, '', $image['name']); $taskAdditionList[$targetWikiId][$wgCityId][] = $image; } $task = new PromoteImageReviewTask(); $task->createTask( array( 'upload_list' => $taskAdditionList, ), TASK_QUEUED ); } wfProfileOut(__METHOD__); }
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; }
protected function createRemovalTask($taskDeletionList) { if (!empty($taskDeletionList) && class_exists('PromoteImageReviewTask')) { $task = new PromoteImageReviewTask(); $task->createTask(array('deletion_list' => $taskDeletionList), TASK_QUEUED); } }