1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

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
This commit is contained in:
epriestley 2014-08-20 15:04:34 -07:00
parent 5ac36e8f77
commit e5acdd85e6
3 changed files with 29 additions and 1 deletions

View file

@ -3575,6 +3575,7 @@ phutil_register_library_map(array(
'HeraldTranscript' => array(
'HeraldDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
'HeraldTranscriptController' => 'HeraldController',
'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector',

View file

@ -1,7 +1,9 @@
<?php
final class HeraldTranscript extends HeraldDAO
implements PhabricatorPolicyInterface {
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $objectTranscript;
protected $ruleTranscripts = array();
@ -196,4 +198,16 @@ final class HeraldTranscript extends HeraldDAO
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}

View file

@ -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
}