diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php index eddc2f73fb..fd7ba7c30a 100644 --- a/src/applications/system/engine/PhabricatorDestructionEngine.php +++ b/src/applications/system/engine/PhabricatorDestructionEngine.php @@ -68,8 +68,30 @@ final class PhabricatorDestructionEngine extends Phobject { } // TODO: Remove stuff from search indexes? - // TODO: PhabricatorFlaggableInterface - // TODO: PhabricatorTokenReceiverInterface + + if ($object instanceof PhabricatorFlaggableInterface) { + $flags = id(new PhabricatorFlag())->loadAllWhere( + 'objectPHID = %s', $object_phid); + + foreach ($flags as $flag) { + $flag->delete(); + } + } + + $flags = id(new PhabricatorFlag())->loadAllWhere( + 'ownerPHID = %s', $object_phid); + foreach ($flags as $flag) { + $flag->delete(); + } + + if ($object instanceof PhabricatorTokenReceiverInterface) { + $tokens = id(new PhabricatorTokenGiven())->loadAllWhere( + 'objectPHID = %s', $object_phid); + + foreach ($tokens as $token) { + $token->delete(); + } + } } private function destroyEdges($src_phid) { @@ -116,7 +138,7 @@ final class PhabricatorDestructionEngine extends Phobject { } private function destroyNotifications($object_phid) { - $table = id(new PhabricatorFeedStoryNotification()); + $table = new PhabricatorFeedStoryNotification(); $conn_w = $table->establishConnection('w'); queryfx(