/** * @param string $task_name * @param int $total_record_qty * @return IBatchTask */ public function buildBatchTask($task_name, $total_record_qty) { $task = new BatchTask(); $task->Name = $task_name; $task->initialize($total_record_qty); return $task; }
function send($raiseIfError = false) { $res = $this->client->request("POST", "/search/batch/dbs/", array(), $this->data); $batch_task = new BatchTask($this->client, $res); if ($raiseIfError && $batch_task->hasError()) { throw new DeepomaticBatchRequestsFailed("One or more requests failed: \n" . json_encode($batch_task->response, JSON_PRETTY_PRINT) . PHP_EOL); } return $batch_task; }
/** * @author Federico "Lox" Lucignano <*****@*****.**> * Performs action for cleaning up temporary data at the very end of a process */ public function cleanup() { //remove phalanx user block if ($this->mPhalanxBlockId) { $ret = PhalanxHelper::removeFilter($this->mPhalanxBlockId, false); if ($ret['error'] == true) { $this->addLog("Error removing Phalanx user block with ID {$this->mPhalanxBlockId}"); } else { $this->addLog("Phalanx user block with ID {$this->mPhalanxBlockId} has been removed"); } } if ($this->mFakeUserId) { $this->addLog("Cleaning up process data in user option renameData for ID {$this->mFakeUserId}"); $fakeUser = User::newFromId($this->mFakeUserId); $fakeUser->setOption('renameData', self::RENAME_TAG . '=' . $this->mNewUsername); $fakeUser->saveSettings(); $fakeUser->saveToCache(); } //TODO: Add a hook $hookName = 'UserRename::Cleanup'; $this->addLog("Broadcasting hook: {$hookName}"); wfRunHooks($hookName, array($this->mRequestorId, $this->mRequestorName, $this->mUserId, $this->mOldUsername, $this->mNewUsername)); $tasks = array(); if (isset($this->mGlobalTask)) { $tasks[] = $this->mGlobalTask->getID(); } if (isset($this->mLogTask)) { $tasks[] = $this->mLogTask->getID(); } $this->addMainLog("finish", RenameUserLogFormatter::finish($this->mRequestorName, $this->mOldUsername, $this->mNewUsername, $this->mReason, $tasks)); }
function __construct($single = false) { $this->mType = 'multidelete'; $this->mVisible = false; //we don't show form for this, it already exists parent::__construct(); }
/** * execute * * Main entry point, TaskManagerExecutor run this method * * @access public * @author bartek@wikia * @author eloy@wikia * * @param mixed $params default null: task params from wikia_tasks table * * @return boolean: status of operation, true = success, false = failure */ function execute($params = null) { global $wgWikiaLocalSettingsPath; $this->mTaskID = $params->task_id; $this->mParams = $params; $task_arguments = unserialize($params->task_arguments); $this->mSourceTaskId = $task_arguments["source-task-id"]; $this->mTargetWikiId = $task_arguments["target-wiki-id"]; #--- get data for previous task $oPreviousTask = BatchTask::newFromID($this->mSourceTaskId); if (is_null($oPreviousTask)) { $this->addLog("Previous task nr {$this->mSourceTaskId} doesn't exist in database"); return false; } $sWorkDir = $oPreviousTask->getTaskDirectory(); $this->addLog("Opennig {$sWorkDir} directory"); $i = 0; while (file_exists(sprintf("%s/%03d_dump.xml", $sWorkDir, $i))) { $phpFile = "php"; $importDumpFile = $GLOBALS["IP"] . "/maintenance/importDump.php"; $command = sprintf("SERVER_ID=%s %s %s --conf %s %s/%03d_dump.xml", $this->mTargetWikiId, $phpFile, $importDumpFile, $wgWikiaLocalSettingsPath, $sWorkDir, $i); $this->addLog("Running: {$command}"); $out = wfShellExec($command, $retval); $this->addLog($out); $i++; } if (empty($i)) { $this->addLog("Nothing was imported. There is no dump file to process"); } return true; }
/** * contructor * @access public */ public function __construct() { $this->mType = "renameuser_global"; $this->mVisible = true; parent::__construct(); $this->mDebug = false; }
/** * contructor */ function __construct() { $this->mType = 'SWMSendToGroup'; $this->mVisible = false; $this->mTTL = 60 * 60 * 12; #--- 12 hours parent::__construct(); }
/** * contructor * @access public */ public function __construct() { $this->mType = "renameuser_local"; $this->mVisible = true; $this->mTTL = self::TTL; parent::__construct(); $this->mDebug = false; }
function doUp() { global $database; $task = BatchTask::get()->filter('Name', SpeakerSelectionAnnouncementSenderManager::TaskName)->first(); if (!is_null($task)) { $task->delete(); } }
/** * contructor * @access public */ public function __construct() { $this->mType = 'wallcopyfollows'; $this->mVisible = true; $this->mTTL = self::TTL; parent::__construct(); $this->mDebug = false; }
/** * contructor */ function __construct() { $this->mType = 'SWMSendToGroup'; $this->mVisible = false; $this->mTTL = 3600; #--- one hour parent::__construct(); }
/** * contructor * @access public */ public function __construct() { $this->mType = "blog"; $this->mVisible = false; $this->mTTL = 1800; parent::__construct(); $this->mDebug = true; }
/** * contructor * @access public */ public function __construct() { parent::__construct(); $this->mType = "local-maintenance"; $this->mVisible = false; $this->mTTL = 1800; $this->mDebug = false; $this->mUseTemplate = false; }
function __construct($single = false) { $this->mType = 'multirestore'; $this->mVisible = false; //we don't show form for this, it already exists $this->mSingle = $single; //single wiki or not (need that for a reason) parent::__construct(); }
function __construct($params = array()) { $this->mType = 'multiwikiedit'; $this->mVisible = false; //we don't show form for this, it already exists $this->mParams = $params; $this->mTTL = 60 * 60 * 24; // 24 hours parent::__construct(); }
function __construct($params = array()) { $this->mType = 'multidelete'; $this->mVisible = false; //we don't show form for this, it already exists $this->mParams = $params; $this->mTTL = 60 * 60 * 24; // 5 hours $this->records = 1000; parent::__construct(); }
function __construct($params = array()) { $this->mType = 'imagereview'; $this->mVisible = false; // do not show form for this task $this->mParams = $params; $this->mTTL = 86400; // 24 hours $this->records = 1000; // TODO: needed? parent::__construct(); }
function __construct($params = array()) { $this->mType = 'promoteimagereview'; $this->mVisible = false; // do not show form for this task $this->mParams = $params; $this->mTTL = 86400; // 24 hours $this->records = 1000; // TODO: needed? $this->initializeSkippedWikiList(); parent::__construct(); }
/** * execute * * main entry point * * @author Inez Korczynski (inez@wikia.com) * @access publiic * * @param array $params: task params * * @return boolean: true if success, false otherwise */ function execute($params = null) { global $wgExternalSharedDB; $aArgs = unserialize($params->task_arguments); $this->mTaskID = $params->task_id; $this->mSourceTaskId = $aArgs["source-task-id"]; $dbr = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); $oRes = $dbr->select("wikia_tasks", "task_arguments", array("task_id" => $this->mSourceTaskId), __METHOD__); $oRow = $dbr->fetchObject($oRes); $aArgsSource = unserialize($oRow->task_arguments); $this->mSourceUrl = $aArgsSource["source-wiki-url"]; $oPreviousTask = BatchTask::newFromID($this->mSourceTaskId); $this->mPrevWorkDir = $oPreviousTask->getTaskDirectory(); $this->addLog("Opening previous task directory {$this->mWorkDir}"); $this->mWorkDir = $this->getTaskDirectory(); $this->mSourceWikiUrl = $this->mSourceUrl; if ($this->exportPageList()) { return true; } return false; }
/** * @author Federico "Lox" Lucignano <*****@*****.**> * Performs action for cleaning up temporary data at the very end of a process */ public function cleanup() { if ($this->mFakeUserId) { $this->addLog("Cleaning up process data in user option renameData for ID {$this->mFakeUserId}"); $fakeUser = User::newFromId($this->mFakeUserId); $fakeUser->setGlobalAttribute('renameData', self::RENAME_TAG . '=' . $this->mNewUsername); $fakeUser->saveSettings(); $fakeUser->saveToCache(); } //TODO: Add a hook $hookName = 'UserRename::Cleanup'; $this->addLog("Broadcasting hook: {$hookName}"); wfRunHooks($hookName, array($this->mRequestorId, $this->mRequestorName, $this->mUserId, $this->mOldUsername, $this->mNewUsername)); $tasks = array(); if (isset($this->mGlobalTask)) { $tasks[] = $this->mGlobalTask->getID(); } if (isset($this->mLogTask)) { $tasks[] = $this->mLogTask->getID(); } $this->addMainLog("finish", RenameUserLogFormatter::finish($this->mRequestorName, $this->mOldUsername, $this->mNewUsername, $this->mReason, $tasks)); }
/** * getPreviousTaskDirectory * * get proper folder for previous task * * @author bartek@wikia * @author eloy@wikia * * @return mixed: path to directory or null if not defined */ public function getPreviousTaskDirectory() { $oPreviousTask = BatchTask::newFromID($this->mGrabberID); return $oPreviousTask->getTaskDirectory(); }
public function __construct() { $this->mType = "userrollback"; $this->mVisible = true; parent::__construct(); }
/** * contructor * @access public */ public function __construct() { parent::__construct(); $this->mType = "welcome"; $this->mVisible = false; $this->mTTL = 1800; $this->mDebug = false; }
/** * checkTTL * * check grace period time for task type i.e. how long task can live * if time to live is longer that TTL value finish it with ERROR status * * @access public * @author eloy@wikia-inc.com * * @param array $ids: identifiers of running tasks * * @return nothing */ public function checkTTL($ids) { if (is_array($ids)) { foreach ($ids as $taskid) { $oTask = BatchTask::newFromID($taskid); if ($oTask && !empty($oTask->getData()->task_started)) { $ttl = $oTask->getTTL(); $run = wfTimestamp(TS_UNIX, $oTask->getData()->task_started); $now = wfTimestamp(); if ($now - $run > $ttl) { #--- kill him! $oTask->addLog("TTL exceeded. Finished by task manager"); $oTask->closeTask(false); /** * alarm mail to ops */ $this->alarmMail($oTask); } else { wfDebugLog("taskmanager", sprintf("Task %d (%s) live %ds, need %ds to kill.", $oTask->getData()->task_id, $oTask->getData()->task_type, $now - $run, $ttl), true); } } else { wfDebugLog("taskmanager", "strange error happen, in running task starting time is empty", true); } } } }
/** * Contructor * * @access public */ public function __construct() { $this->mType = "update_special_pages"; $this->mVisible = true; parent::__construct(); }
/** * Contructor * * @access public */ public function __construct() { $this->mType = "rebuild_localisation_cache"; $this->mVisible = true; parent::__construct(); }
/** * contructor * * @access public * @author eloy * * @return RemoveWikiTask object */ public function __construct() { $this->mType = "removewiki"; $this->mVisible = true; parent::__construct(); }
/** * contructor */ function __construct() { $this->mType = "closewiki"; $this->mVisible = true; parent::__construct(); }
function getForm() { global $wgWikiaBatchTasks, $wgRequest; $aSorting = array(); $iStatus = $wgRequest->getVal("wpStatus"); $sType = $wgRequest->getArray("wpType"); #--- get data from session if (!empty($_SESSION["taskmanager.filters"])) { $aSorting = $_SESSION["taskmanager.filters"]; } if (!is_null($iStatus)) { if ($iStatus != -1) { $aSorting["task_status"] = $iStatus; } else { unset($aSorting["task_status"]); } } if (!is_null($sType) || $wgRequest->wasPosted()) { if (count($sType) != 0) { $aSorting["task_type"] = $sType; } else { unset($aSorting["task_type"]); } } $this->mQueryConds = $aSorting; $_SESSION["taskmanager.filters"] = $aSorting; $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("title" => $this->mTitle, "types" => $wgWikiaBatchTasks, "current" => $this->mQueryConds, "statuses" => BatchTask::getStatuses())); return $oTmpl->render("form"); }
function __construct() { $this->mType = 'pagegrabber'; $this->mVisible = true; parent::__construct(); }