From e5acdd85e68197d6d63b2fa6c055cd9aa1d0ca2c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Aug 2014 15:04:34 -0700 Subject: [PATCH] When destroying an object, destroy its Herald transcripts too Summary: Ref T5915. Make `bin/remove destroy` a bit more thorough, since Herald transcripts can have field information in them. Test Plan: Used `bin/remove destroy` to nuke revisions, saw their transcripts vanish too. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5915 Differential Revision: https://secure.phabricator.com/D10306 --- src/__phutil_library_map__.php | 1 + .../storage/transcript/HeraldTranscript.php | 16 +++++++++++++++- .../engine/PhabricatorDestructionEngine.php | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 9987ef205a..cd892ee172 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3575,6 +3575,7 @@ phutil_register_library_map(array( 'HeraldTranscript' => array( 'HeraldDAO', 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'HeraldTranscriptController' => 'HeraldController', 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', diff --git a/src/applications/herald/storage/transcript/HeraldTranscript.php b/src/applications/herald/storage/transcript/HeraldTranscript.php index 2e2d4858ec..50387d2cc2 100644 --- a/src/applications/herald/storage/transcript/HeraldTranscript.php +++ b/src/applications/herald/storage/transcript/HeraldTranscript.php @@ -1,7 +1,9 @@ openTransaction(); + $this->delete(); + $this->saveTransaction(); + } + + } diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php index 4c49ac6ae2..e1f1045132 100644 --- a/src/applications/system/engine/PhabricatorDestructionEngine.php +++ b/src/applications/system/engine/PhabricatorDestructionEngine.php @@ -48,6 +48,19 @@ final class PhabricatorDestructionEngine extends Phobject { } } + // Nuke any Herald transcripts of the object, because they may contain + // field data. + + // TODO: Define an interface so we don't have to do this for transactions + // and other objects with no Herald adapters? + $transcripts = id(new HeraldTranscript())->loadAllWhere( + 'objectPHID = %s', + $object_phid); + foreach ($transcripts as $transcript) { + $transcript->destroyObjectPermanently($this); + } + + // TODO: Remove stuff from search indexes? // TODO: PhabricatorFlaggableInterface // TODO: PhabricatorTokenReceiverInterface }