Page MenuHomePhabricator

D21630.id51492.diff
No OneTemporary

D21630.id51492.diff

diff --git a/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php b/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php
@@ -0,0 +1,28 @@
+<?php
+
+$binding_table = new AlmanacBinding();
+$binding_conn = $binding_table->establishConnection('w');
+
+$properties_table = new PhabricatorMetaMTAMailProperties();
+$conn = $properties_table->establishConnection('w');
+
+$iterator = new LiskRawMigrationIterator(
+ $binding_conn,
+ $binding_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());
+}
diff --git a/resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql b/resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_almanac.almanac_binding
+ DROP mailKey;
diff --git a/src/applications/almanac/storage/AlmanacBinding.php b/src/applications/almanac/storage/AlmanacBinding.php
--- a/src/applications/almanac/storage/AlmanacBinding.php
+++ b/src/applications/almanac/storage/AlmanacBinding.php
@@ -13,7 +13,6 @@
protected $servicePHID;
protected $devicePHID;
protected $interfacePHID;
- protected $mailKey;
protected $isDisabled;
private $service = self::ATTACHABLE;
@@ -33,7 +32,6 @@
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
- 'mailKey' => 'bytes20',
'isDisabled' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
@@ -51,15 +49,8 @@
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(AlmanacBindingPHIDType::TYPECONST);
- }
-
- public function save() {
- if (!$this->mailKey) {
- $this->mailKey = Filesystem::readRandomCharacters(20);
- }
- return parent::save();
+ public function getPHIDType() {
+ return AlmanacBindingPHIDType::TYPECONST;
}
public function getName() {
@@ -67,7 +58,9 @@
}
public function getURI() {
- return '/almanac/binding/'.$this->getID().'/';
+ return urisprintf(
+ '/almanac/binding/%s/',
+ $this->getID());
}
public function getService() {

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 4:25 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7573997
Default Alt Text
D21630.id51492.diff (2 KB)

Event Timeline