From 50f4adef64cfee615f3bc4638e7328e864bca00c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 29 Aug 2018 08:22:53 -0700 Subject: [PATCH] Remove on-object mailkeys from Phriction Summary: Depends on D19619. Ref T13065. Ref T13077. Migrate Phriction mail keys to the new infrastructure and drop the column. Test Plan: Ran migrations, spot-checked the database. Reviewers: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13077, T13065 Differential Revision: https://secure.phabricator.com/D19620 --- .../20180829.phriction.01.mailkey.php | 26 +++++++++++++++++++ .../20180829.phriction.02.rmkey.sql | 2 ++ .../phriction/storage/PhrictionDocument.php | 15 +++-------- 3 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 resources/sql/autopatches/20180829.phriction.01.mailkey.php create mode 100644 resources/sql/autopatches/20180829.phriction.02.rmkey.sql diff --git a/resources/sql/autopatches/20180829.phriction.01.mailkey.php b/resources/sql/autopatches/20180829.phriction.01.mailkey.php new file mode 100644 index 0000000000..cb85a3c5ef --- /dev/null +++ b/resources/sql/autopatches/20180829.phriction.01.mailkey.php @@ -0,0 +1,26 @@ +establishConnection('w'); +$document_name = $document_table->getTableName(); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator($document_conn, $document_name); +foreach ($iterator as $row) { + queryfx( + $conn, + 'INSERT IGNORE INTO %T + (objectPHID, mailProperties, dateCreated, dateModified) + VALUES + (%s, %s, %d, %d)', + $properties_table->getTableName(), + $row['phid'], + phutil_json_encode( + array( + 'mailKey' => $row['mailKey'], + )), + PhabricatorTime::getNow(), + PhabricatorTime::getNow()); +} diff --git a/resources/sql/autopatches/20180829.phriction.02.rmkey.sql b/resources/sql/autopatches/20180829.phriction.02.rmkey.sql new file mode 100644 index 0000000000..8199287db7 --- /dev/null +++ b/resources/sql/autopatches/20180829.phriction.02.rmkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_phriction.phriction_document + DROP mailKey; diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 0e260c2e40..626d02c1db 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -19,7 +19,6 @@ final class PhrictionDocument extends PhrictionDAO protected $depth; protected $contentPHID; protected $status; - protected $mailKey; protected $viewPolicy; protected $editPolicy; protected $spacePHID; @@ -36,7 +35,6 @@ final class PhrictionDocument extends PhrictionDAO 'slug' => 'sort128', 'depth' => 'uint32', 'status' => 'text32', - 'mailKey' => 'bytes20', 'editedEpoch' => 'epoch', ), self::CONFIG_KEY_SCHEMA => array( @@ -95,13 +93,6 @@ final class PhrictionDocument extends PhrictionDAO return $document; } - public function save() { - if (!$this->getMailKey()) { - $this->setMailKey(Filesystem::readRandomCharacters(20)); - } - return parent::save(); - } - public static function getSlugURI($slug, $type = 'document') { static $types = array( 'document' => '/w/', @@ -329,9 +320,9 @@ final class PhrictionDocument extends PhrictionDAO /* -( PhabricatorPolicyCodexInterface )------------------------------------ */ - public function newPolicyCodex() { - return new PhrictionDocumentPolicyCodex(); - } + public function newPolicyCodex() { + return new PhrictionDocumentPolicyCodex(); + } }