1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

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
This commit is contained in:
Joshua Spence 2015-05-14 06:49:30 +10:00
parent f677394b6f
commit f3d5e22a45

View file

@ -46,6 +46,9 @@ final class PhabricatorDestructionEngine extends Phobject {
$template = $object->getApplicationTransactionTemplate();
$this->destroyTransactions($template, $object_phid);
}
$this->destroyWorkerTasks($object_phid);
$this->destroyNotifications($object_phid);
}
// Nuke any Herald transcripts of the object, because they may contain
@ -94,7 +97,28 @@ final class PhabricatorDestructionEngine extends Phobject {
foreach ($xactions as $xaction) {
$this->destroyObject($xaction);
}
}
private function destroyWorkerTasks($object_phid) {
$tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
'objectPHID = %s',
$object_phid);
foreach ($tasks as $task) {
$task->archiveTask(
PhabricatorWorkerArchiveTask::RESULT_CANCELLED,
0);
}
}
private function destroyNotifications($object_phid) {
$notifications = id(new PhabricatorFeedStoryNotification())->loadAllWhere(
'primaryObjectPHID = %s',
$object_phid);
foreach ($notifications as $notification) {
$notification->delete();
}
}
}