diff --git a/resources/sql/autopatches/20180829.phriction.01.mailkey.php b/resources/sql/autopatches/20180829.phriction.01.mailkey.php new file mode 100644 --- /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 --- /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 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -19,7 +19,6 @@ protected $depth; protected $contentPHID; protected $status; - protected $mailKey; protected $viewPolicy; protected $editPolicy; protected $spacePHID; @@ -36,7 +35,6 @@ 'slug' => 'sort128', 'depth' => 'uint32', 'status' => 'text32', - 'mailKey' => 'bytes20', 'editedEpoch' => 'epoch', ), self::CONFIG_KEY_SCHEMA => array( @@ -95,13 +93,6 @@ 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 @@ /* -( PhabricatorPolicyCodexInterface )------------------------------------ */ - public function newPolicyCodex() { - return new PhrictionDocumentPolicyCodex(); - } + public function newPolicyCodex() { + return new PhrictionDocumentPolicyCodex(); + } }