1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Migrate "SlowvotePoll" to modern mailkey storage

Summary:
Ref T13682. Ref T13065. Migrate and update "SlowvotePoll" to use more modern mailkey storage (in the mail application, rather than onboard).

Also make other minor modernization changes.

Test Plan: Created a new poll. Ran migration, verified mail key copied properly in database.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13682, T13065

Differential Revision: https://secure.phabricator.com/D21842
This commit is contained in:
epriestley 2022-05-25 17:07:37 -07:00
parent d91727e66c
commit b1533e5468
3 changed files with 34 additions and 13 deletions

View file

@ -0,0 +1,28 @@
<?php
$poll_table = new PhabricatorSlowvotePoll();
$poll_conn = $poll_table->establishConnection('w');
$properties_table = new PhabricatorMetaMTAMailProperties();
$conn = $properties_table->establishConnection('w');
$iterator = new LiskRawMigrationIterator(
$poll_conn,
$poll_table->getTableName());
foreach ($iterator as $row) {
queryfx(
$conn,
'INSERT IGNORE INTO %R
(objectPHID, mailProperties, dateCreated, dateModified)
VALUES
(%s, %s, %d, %d)',
$properties_table,
$row['phid'],
phutil_json_encode(
array(
'mailKey' => $row['mailKey'],
)),
PhabricatorTime::getNow(),
PhabricatorTime::getNow());
}

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
DROP mailKey;

View file

@ -1,6 +1,7 @@
<?php
final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
final class PhabricatorSlowvotePoll
extends PhabricatorSlowvoteDAO
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
@ -25,7 +26,6 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
protected $responseVisibility = 0;
protected $shuffle = 0;
protected $method;
protected $mailKey;
protected $viewPolicy;
protected $isClosed = 0;
protected $spacePHID;
@ -59,16 +59,14 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
'method' => 'uint32',
'description' => 'text',
'isClosed' => 'bool',
'mailKey' => 'bytes20',
),
self::CONFIG_KEY_SCHEMA => array(
),
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorSlowvotePollPHIDType::TYPECONST);
public function getPHIDType() {
return PhabricatorSlowvotePollPHIDType::TYPECONST;
}
public function getOptions() {
@ -112,13 +110,6 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
return '/'.$this->getMonogram();
}
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */