mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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
|
<?php
|
||||||
|
|
||||||
final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
final class PhabricatorSlowvotePoll
|
||||||
|
extends PhabricatorSlowvoteDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
|
@ -25,7 +26,6 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||||
protected $responseVisibility = 0;
|
protected $responseVisibility = 0;
|
||||||
protected $shuffle = 0;
|
protected $shuffle = 0;
|
||||||
protected $method;
|
protected $method;
|
||||||
protected $mailKey;
|
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $isClosed = 0;
|
protected $isClosed = 0;
|
||||||
protected $spacePHID;
|
protected $spacePHID;
|
||||||
|
@ -59,16 +59,14 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||||
'method' => 'uint32',
|
'method' => 'uint32',
|
||||||
'description' => 'text',
|
'description' => 'text',
|
||||||
'isClosed' => 'bool',
|
'isClosed' => 'bool',
|
||||||
'mailKey' => 'bytes20',
|
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generatePHID() {
|
public function getPHIDType() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorSlowvotePollPHIDType::TYPECONST;
|
||||||
PhabricatorSlowvotePollPHIDType::TYPECONST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptions() {
|
public function getOptions() {
|
||||||
|
@ -112,13 +110,6 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||||
return '/'.$this->getMonogram();
|
return '/'.$this->getMonogram();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
|
||||||
if (!$this->getMailKey()) {
|
|
||||||
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
|
||||||
}
|
|
||||||
return parent::save();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue