@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.

Destroy associated worker tasks and notifications

Summary: Fixes T7107. When destroying an object, destroy associated worker tasks and notifications.

Test Plan:
# Manually updated the `phabricator_worker.worker_activetask` table by setting `objectPHID` to the desired object.
# Removed object with `./bin/remove destroy`.
# Queried `phabricator_worker.worker_activetask` table.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7107

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

+24
+24
src/applications/system/engine/PhabricatorDestructionEngine.php
··· 46 46 $template = $object->getApplicationTransactionTemplate(); 47 47 $this->destroyTransactions($template, $object_phid); 48 48 } 49 + 50 + $this->destroyWorkerTasks($object_phid); 51 + $this->destroyNotifications($object_phid); 49 52 } 50 53 51 54 // Nuke any Herald transcripts of the object, because they may contain ··· 94 97 foreach ($xactions as $xaction) { 95 98 $this->destroyObject($xaction); 96 99 } 100 + } 97 101 102 + private function destroyWorkerTasks($object_phid) { 103 + $tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere( 104 + 'objectPHID = %s', 105 + $object_phid); 106 + 107 + foreach ($tasks as $task) { 108 + $task->archiveTask( 109 + PhabricatorWorkerArchiveTask::RESULT_CANCELLED, 110 + 0); 111 + } 112 + } 113 + 114 + private function destroyNotifications($object_phid) { 115 + $notifications = id(new PhabricatorFeedStoryNotification())->loadAllWhere( 116 + 'primaryObjectPHID = %s', 117 + $object_phid); 118 + 119 + foreach ($notifications as $notification) { 120 + $notification->delete(); 121 + } 98 122 } 99 123 100 124 }