Skip to content

Commit b1533e5

Browse files
author
epriestley
committedMay 26, 2022
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
1 parent d91727e commit b1533e5

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$poll_table = new PhabricatorSlowvotePoll();
4+
$poll_conn = $poll_table->establishConnection('w');
5+
6+
$properties_table = new PhabricatorMetaMTAMailProperties();
7+
$conn = $properties_table->establishConnection('w');
8+
9+
$iterator = new LiskRawMigrationIterator(
10+
$poll_conn,
11+
$poll_table->getTableName());
12+
13+
foreach ($iterator as $row) {
14+
queryfx(
15+
$conn,
16+
'INSERT IGNORE INTO %R
17+
(objectPHID, mailProperties, dateCreated, dateModified)
18+
VALUES
19+
(%s, %s, %d, %d)',
20+
$properties_table,
21+
$row['phid'],
22+
phutil_json_encode(
23+
array(
24+
'mailKey' => $row['mailKey'],
25+
)),
26+
PhabricatorTime::getNow(),
27+
PhabricatorTime::getNow());
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
2+
DROP mailKey;

‎src/applications/slowvote/storage/PhabricatorSlowvotePoll.php

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
3+
final class PhabricatorSlowvotePoll
4+
extends PhabricatorSlowvoteDAO
45
implements
56
PhabricatorApplicationTransactionInterface,
67
PhabricatorPolicyInterface,
@@ -25,7 +26,6 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
2526
protected $responseVisibility = 0;
2627
protected $shuffle = 0;
2728
protected $method;
28-
protected $mailKey;
2929
protected $viewPolicy;
3030
protected $isClosed = 0;
3131
protected $spacePHID;
@@ -59,16 +59,14 @@ protected function getConfiguration() {
5959
'method' => 'uint32',
6060
'description' => 'text',
6161
'isClosed' => 'bool',
62-
'mailKey' => 'bytes20',
6362
),
6463
self::CONFIG_KEY_SCHEMA => array(
6564
),
6665
) + parent::getConfiguration();
6766
}
6867

69-
public function generatePHID() {
70-
return PhabricatorPHID::generateNewPHID(
71-
PhabricatorSlowvotePollPHIDType::TYPECONST);
68+
public function getPHIDType() {
69+
return PhabricatorSlowvotePollPHIDType::TYPECONST;
7270
}
7371

7472
public function getOptions() {
@@ -112,13 +110,6 @@ public function getURI() {
112110
return '/'.$this->getMonogram();
113111
}
114112

115-
public function save() {
116-
if (!$this->getMailKey()) {
117-
$this->setMailKey(Filesystem::readRandomCharacters(20));
118-
}
119-
return parent::save();
120-
}
121-
122113

123114
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
124115

0 commit comments

Comments
 (0)
Failed to load comments.