mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01: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:
parent
d91727e66c
commit
b1533e5468
3 changed files with 34 additions and 13 deletions
28
resources/sql/autopatches/20220525.slowvote.01.mailkey.php
Normal file
28
resources/sql/autopatches/20220525.slowvote.01.mailkey.php
Normal 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());
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
|
||||
DROP mailKey;
|
|
@ -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 )------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue