@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+14 -16
+1
src/__phutil_library_map__.php
··· 8739 8739 'PhabricatorMetaMTAMail' => array( 8740 8740 'PhabricatorMetaMTADAO', 8741 8741 'PhabricatorPolicyInterface', 8742 + 'PhabricatorDestructibleInterface', 8742 8743 ), 8743 8744 'PhabricatorMetaMTAMailBody' => 'Phobject', 8744 8745 'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
+2 -1
src/applications/metamta/garbagecollector/MetaMTAMailSentGarbageCollector.php
··· 18 18 'dateCreated < %d LIMIT 100', 19 19 $this->getGarbageEpoch()); 20 20 21 + $engine = new PhabricatorDestructionEngine(); 21 22 foreach ($mails as $mail) { 22 - $mail->delete(); 23 + $engine->destroyObject($mail); 23 24 } 24 25 25 26 return (count($mails) == 100);
+11 -15
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
··· 5 5 */ 6 6 final class PhabricatorMetaMTAMail 7 7 extends PhabricatorMetaMTADAO 8 - implements PhabricatorPolicyInterface { 8 + implements 9 + PhabricatorPolicyInterface, 10 + PhabricatorDestructibleInterface { 9 11 10 12 const RETRY_DELAY = 5; 11 13 ··· 1041 1043 } 1042 1044 } 1043 1045 1044 - public function delete() { 1045 - $this->openTransaction(); 1046 - queryfx( 1047 - $this->establishConnection('w'), 1048 - 'DELETE FROM %T WHERE src = %s AND type = %d', 1049 - PhabricatorEdgeConfig::TABLE_NAME_EDGE, 1050 - $this->getPHID(), 1051 - PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); 1052 - $ret = parent::delete(); 1053 - $this->saveTransaction(); 1054 - 1055 - return $ret; 1056 - } 1057 - 1058 1046 public function generateHeaders() { 1059 1047 $headers = array(); 1060 1048 ··· 1305 1293 'The mail sender and message recipients can always see the mail.'); 1306 1294 } 1307 1295 1296 + 1297 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 1298 + 1299 + 1300 + public function destroyObjectPermanently( 1301 + PhabricatorDestructionEngine $engine) { 1302 + $this->delete(); 1303 + } 1308 1304 1309 1305 }