From 63ce0e66c926222a5a805d5199c8ea98cc4bc129 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 11:38:09 +1000 Subject: [PATCH] Allow Phriction documents to be permanently deleted Summary: Allow `PhrictionDocument` to be permanently deleted with `./bin/remove destroy`. Test Plan: Deleted a Phriction document with `./bin/remove` and verified that the database was in the expected state. ``` > ./bin/remove destroy PHID-WIKI-auj57rauigvcqvv5feh6 IMPORTANT: OBJECTS WILL BE PERMANENTLY DESTROYED! There is no way to undo this operation or ever retrieve this data. These 1 object(s) will be completely destroyed forever: - PHID-WIKI-auj57rauigvcqvv5feh6 (PhrictionDocument) Are you absolutely certain you want to destroy these 1 object(s)? [y/N] y Destroying objects... Destroying PhrictionDocument PHID-WIKI-auj57rauigvcqvv5feh6... Permanently destroyed 1 object(s). ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9976 --- .../phriction/storage/PhrictionDocument.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 8c5b5d58bc..07a3d5ec0f 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -5,7 +5,8 @@ final class PhrictionDocument extends PhrictionDAO PhabricatorPolicyInterface, PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, - PhabricatorTokenReceiverInterface { + PhabricatorTokenReceiverInterface, + PhabricatorDestructableInterface { protected $slug; protected $depth; @@ -180,4 +181,26 @@ final class PhrictionDocument extends PhrictionDAO public function getUsersToNotifyOfTokenGiven() { return PhabricatorSubscribersQuery::loadSubscribersForPHID($this->phid); } + + +/* -( PhabricatorDestructableInterface )----------------------------------- */ + + + public function destroyObjectPermanently( + PhabricatorDestructionEngine $engine) { + + $this->openTransaction(); + + $this->delete(); + + $contents = id(new PhrictionContent())->loadAllWhere( + 'documentID = %d', + $this->getID()); + foreach ($contents as $content) { + $content->delete(); + } + + $this->saveTransaction(); + } + } -- 2.51.2