From 17376927e55ee481c741494dee3c91a6c80bdded Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Aug 2014 08:41:03 -0700 Subject: [PATCH] Allow Ponder questions and answers to be destroyed with bin/remove Summary: Ref T5847. Test Plan: Used `bin/remove destroy` to destroy a question. Saw the question and its answers get wiped out. Reviewers: btrahan, shadowhand Reviewed By: shadowhand Subscribers: shadowhand, epriestley Maniphest Tasks: T5847 Differential Revision: https://secure.phabricator.com/D10345 --- .../ponder/storage/PonderAnswer.php | 15 ++++++++++++- .../ponder/storage/PonderQuestion.php | 21 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php index 08f66b29dc..9385200842 100644 --- a/src/applications/ponder/storage/PonderAnswer.php +++ b/src/applications/ponder/storage/PonderAnswer.php @@ -7,7 +7,8 @@ final class PonderAnswer extends PonderDAO PhabricatorPolicyInterface, PhabricatorFlaggableInterface, PhabricatorSubscribableInterface, - PhabricatorTokenReceiverInterface { + PhabricatorTokenReceiverInterface, + PhabricatorDestructibleInterface { const MARKUP_FIELD_CONTENT = 'markup:content'; @@ -195,4 +196,16 @@ final class PonderAnswer extends PonderDAO return true; } + +/* -( PhabricatorDestructibleInterface )----------------------------------- */ + + + public function destroyObjectPermanently( + PhabricatorDestructionEngine $engine) { + + $this->openTransaction(); + $this->delete(); + $this->saveTransaction(); + } + } diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index 1de5dea293..f6dd7021f4 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -8,7 +8,8 @@ final class PonderQuestion extends PonderDAO PhabricatorFlaggableInterface, PhabricatorPolicyInterface, PhabricatorTokenReceiverInterface, - PhabricatorProjectInterface { + PhabricatorProjectInterface, + PhabricatorDestructibleInterface { const MARKUP_FIELD_CONTENT = 'markup:content'; @@ -247,4 +248,22 @@ final class PonderQuestion extends PonderDAO ); } + +/* -( PhabricatorDestructibleInterface )----------------------------------- */ + + public function destroyObjectPermanently( + PhabricatorDestructionEngine $engine) { + + $this->openTransaction(); + $answers = id(new PonderAnswer())->loadAllWhere( + 'questionID = %d', + $this->getID()); + foreach ($answers as $answer) { + $engine->destroyObject($answer); + } + + $this->delete(); + $this->saveTransaction(); + } + } -- 2.54.0