From 1e2bc7775bc45300bb383b2332bada6c9af21662 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 20 Dec 2018 11:53:40 -0800 Subject: [PATCH] Remove the onboard "mailKey" from Pholio Mocks Summary: Depends on D19921. Ref T11351. Ref T13065. Update Pholio to use the shared mail infrastructure. See D19670 for a previous change in this vein. Test Plan: Ran upgrade, spot-checked that everything made it into the new table alive. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13065, T11351 Differential Revision: https://secure.phabricator.com/D19922 --- .../20181220.pholio.01.mailkey.php | 28 +++++++++++++++++++ .../20181220.pholio.02.dropmailkey.sql | 2 ++ .../pholio/storage/PholioMock.php | 18 ++---------- 3 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 resources/sql/autopatches/20181220.pholio.01.mailkey.php create mode 100644 resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql diff --git a/resources/sql/autopatches/20181220.pholio.01.mailkey.php b/resources/sql/autopatches/20181220.pholio.01.mailkey.php new file mode 100644 index 0000000000..37dcfd1434 --- /dev/null +++ b/resources/sql/autopatches/20181220.pholio.01.mailkey.php @@ -0,0 +1,28 @@ +establishConnection('w'); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator( + $mock_conn, + $mock_table->getTableName()); + +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/20181220.pholio.02.dropmailkey.sql b/resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql new file mode 100644 index 0000000000..a71bc5dc69 --- /dev/null +++ b/resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_pholio.pholio_mock + DROP mailKey; diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php index 0e61ffc2d1..25b216ba5d 100644 --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -25,7 +25,6 @@ final class PholioMock extends PholioDAO protected $name; protected $description; protected $coverPHID; - protected $mailKey; protected $status; protected $spacePHID; @@ -65,15 +64,9 @@ final class PholioMock extends PholioDAO self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text128', 'description' => 'text', - 'mailKey' => 'bytes20', 'status' => 'text12', ), self::CONFIG_KEY_SCHEMA => array( - 'key_phid' => null, - 'phid' => array( - 'columns' => array('phid'), - 'unique' => true, - ), 'authorPHID' => array( 'columns' => array('authorPHID'), ), @@ -81,15 +74,8 @@ final class PholioMock extends PholioDAO ) + parent::getConfiguration(); } - public function generatePHID() { - return PhabricatorPHID::generateNewPHID('MOCK'); - } - - public function save() { - if (!$this->getMailKey()) { - $this->setMailKey(Filesystem::readRandomCharacters(20)); - } - return parent::save(); + public function getPHIDType() { + return PholioMockPHIDType::TYPECONST; } public function attachImages(array $images) {