mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 23:40:57 +01:00
Support DestructionEngine in MetaMTAMail
Summary: Depends on D18984. Ref T13053. See D13408 for the original change and why this doesn't use DestructionEngine right now. The quick version is: - It causes us to write a destruction log, which is slightly silly (we're deleting one thing and creating another). - It's a little bit slower than not using DestructionEngine. However, it gets us some stuff for free that's likely relevant now (e.g., Herald Transcript cleanup) and I'm planning to move attachments to Files, but want to be able to delete them when mail is destroyed. The destruction log is a touch silly, but those records are very small and that log gets GC'd later without generating new logs. We could silence the log from the GC if it's ever an issue. Test Plan: Used `bin/remove destroy` and `bin/garbage collect --collector mail.sent` to destroy mail and collect garbage. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13053 Differential Revision: https://secure.phabricator.com/D18985
This commit is contained in:
parent
cbe4e68c07
commit
eb06aca951
3 changed files with 14 additions and 16 deletions
|
@ -8739,6 +8739,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMetaMTAMail' => array(
|
||||
'PhabricatorMetaMTADAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorMetaMTAMailBody' => 'Phobject',
|
||||
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
|
||||
|
|
|
@ -18,8 +18,9 @@ final class MetaMTAMailSentGarbageCollector
|
|||
'dateCreated < %d LIMIT 100',
|
||||
$this->getGarbageEpoch());
|
||||
|
||||
$engine = new PhabricatorDestructionEngine();
|
||||
foreach ($mails as $mail) {
|
||||
$mail->delete();
|
||||
$engine->destroyObject($mail);
|
||||
}
|
||||
|
||||
return (count($mails) == 100);
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
*/
|
||||
final class PhabricatorMetaMTAMail
|
||||
extends PhabricatorMetaMTADAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
||||
const RETRY_DELAY = 5;
|
||||
|
||||
|
@ -1041,20 +1043,6 @@ final class PhabricatorMetaMTAMail
|
|||
}
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->openTransaction();
|
||||
queryfx(
|
||||
$this->establishConnection('w'),
|
||||
'DELETE FROM %T WHERE src = %s AND type = %d',
|
||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
|
||||
$this->getPHID(),
|
||||
PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
|
||||
$ret = parent::delete();
|
||||
$this->saveTransaction();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function generateHeaders() {
|
||||
$headers = array();
|
||||
|
||||
|
@ -1306,4 +1294,12 @@ final class PhabricatorMetaMTAMail
|
|||
}
|
||||
|
||||
|
||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||
|
||||
|
||||
public function destroyObjectPermanently(
|
||||
PhabricatorDestructionEngine $engine) {
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue