@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow PhabricatorWorker->queueTask() to take full $options

Summary:
Ref T9252. Currently, `queueTask()` accepts `$priority` as its third argument. Allow it to take a full range of `$options` instead. This API just never got updated after we expanded avialable options.

Arguably this whole API should be some kind of "TaskQueueRequest" object but I'll leave that for another day.

Test Plan:
- Grepped for `queueTask()` and verified no other callsites are affected by this API change.
- Ran some daemons.
- See also next diff.

Reviewers: hach-que, chad

Reviewed By: hach-que, chad

Maniphest Tasks: T9252

Differential Revision: https://secure.phabricator.com/D14235

+15 -12
+7 -5
src/infrastructure/daemon/workers/PhabricatorWorker.php
··· 160 160 try { 161 161 $worker->doWork(); 162 162 foreach ($worker->getQueuedTasks() as $queued_task) { 163 - list($queued_class, $queued_data, $queued_priority) = $queued_task; 164 - $queued_options = array('priority' => $queued_priority); 163 + list($queued_class, $queued_data, $queued_options) = $queued_task; 165 164 self::scheduleTask($queued_class, $queued_data, $queued_options); 166 165 } 167 166 break; ··· 220 219 * 221 220 * @param string Task class to queue. 222 221 * @param array Data for the followup task. 223 - * @param int|null Priority for the followup task. 222 + * @param array Options for the followup task. 224 223 * @return this 225 224 */ 226 - final protected function queueTask($class, array $data, $priority = null) { 227 - $this->queuedTasks[] = array($class, $data, $priority); 225 + final protected function queueTask( 226 + $class, 227 + array $data, 228 + array $options = array()) { 229 + $this->queuedTasks[] = array($class, $data, $options); 228 230 return $this; 229 231 } 230 232
+8 -7
src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
··· 217 217 // so execute it out here and just let the exception escape. 218 218 if ($did_succeed) { 219 219 foreach ($worker->getQueuedTasks() as $task) { 220 - list($class, $data) = $task; 221 - PhabricatorWorker::scheduleTask( 222 - $class, 223 - $data, 224 - array( 225 - 'priority' => (int)$this->getPriority(), 226 - )); 220 + list($class, $data, $options) = $task; 221 + 222 + // Default the new task priority to our own priority. 223 + $options = $options + array( 224 + 'priority' => (int)$this->getPriority(), 225 + ); 226 + 227 + PhabricatorWorker::scheduleTask($class, $data, $options); 227 228 } 228 229 } 229 230