@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize "mailKey" for Almanac Bindings

Summary: Ref T13065. Ref T13641. Migrate "mailKey" and drop the column.

Test Plan: Ran "bin/storage upgrade", got a clean report and saw binding mail keys in the mail properties table.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13641, T13065

Differential Revision: https://secure.phabricator.com/D21630

+35 -12
+28
resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php
··· 1 + <?php 2 + 3 + $binding_table = new AlmanacBinding(); 4 + $binding_conn = $binding_table->establishConnection('w'); 5 + 6 + $properties_table = new PhabricatorMetaMTAMailProperties(); 7 + $conn = $properties_table->establishConnection('w'); 8 + 9 + $iterator = new LiskRawMigrationIterator( 10 + $binding_conn, 11 + $binding_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 + }
+2
resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql
··· 1 + ALTER TABLE {$NAMESPACE}_almanac.almanac_binding 2 + DROP mailKey;
+5 -12
src/applications/almanac/storage/AlmanacBinding.php
··· 13 13 protected $servicePHID; 14 14 protected $devicePHID; 15 15 protected $interfacePHID; 16 - protected $mailKey; 17 16 protected $isDisabled; 18 17 19 18 private $service = self::ATTACHABLE; ··· 33 32 return array( 34 33 self::CONFIG_AUX_PHID => true, 35 34 self::CONFIG_COLUMN_SCHEMA => array( 36 - 'mailKey' => 'bytes20', 37 35 'isDisabled' => 'bool', 38 36 ), 39 37 self::CONFIG_KEY_SCHEMA => array( ··· 51 49 ) + parent::getConfiguration(); 52 50 } 53 51 54 - public function generatePHID() { 55 - return PhabricatorPHID::generateNewPHID(AlmanacBindingPHIDType::TYPECONST); 56 - } 57 - 58 - public function save() { 59 - if (!$this->mailKey) { 60 - $this->mailKey = Filesystem::readRandomCharacters(20); 61 - } 62 - return parent::save(); 52 + public function getPHIDType() { 53 + return AlmanacBindingPHIDType::TYPECONST; 63 54 } 64 55 65 56 public function getName() { ··· 67 58 } 68 59 69 60 public function getURI() { 70 - return '/almanac/binding/'.$this->getID().'/'; 61 + return urisprintf( 62 + '/almanac/binding/%s/', 63 + $this->getID()); 71 64 } 72 65 73 66 public function getService() {