@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

Modernize "mailKey" for Calendar Event

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

Test Plan: Ran "bin/storage upgrade", got a clean report, saw migrated data in mail properties table.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13065

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

+32 -9
+28
resources/sql/autopatches/20210316.almanac.13.event-mailkey.php
··· 1 + <?php 2 + 3 + $event_table = new PhabricatorCalendarEvent(); 4 + $event_conn = $event_table->establishConnection('w'); 5 + 6 + $properties_table = new PhabricatorMetaMTAMailProperties(); 7 + $conn = $properties_table->establishConnection('w'); 8 + 9 + $iterator = new LiskRawMigrationIterator( 10 + $event_conn, 11 + $event_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.14.event-dropmailkey.sql
··· 1 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 2 + DROP mailKey;
+2 -9
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 24 24 protected $isCancelled; 25 25 protected $isAllDay; 26 26 protected $icon; 27 - protected $mailKey; 28 27 protected $isStub; 29 28 30 29 protected $isRecurring = 0; ··· 360 359 } 361 360 362 361 public function save() { 363 - if (!$this->mailKey) { 364 - $this->mailKey = Filesystem::readRandomCharacters(20); 365 - } 366 - 367 362 $import_uid = $this->getImportUID(); 368 363 if ($import_uid !== null) { 369 364 $index = PhabricatorHash::digestForIndex($import_uid); ··· 405 400 'isCancelled' => 'bool', 406 401 'isAllDay' => 'bool', 407 402 'icon' => 'text32', 408 - 'mailKey' => 'bytes20', 409 403 'isRecurring' => 'bool', 410 404 'seriesParentPHID' => 'phid?', 411 405 'instanceOfEventPHID' => 'phid?', ··· 442 436 ) + parent::getConfiguration(); 443 437 } 444 438 445 - public function generatePHID() { 446 - return PhabricatorPHID::generateNewPHID( 447 - PhabricatorCalendarEventPHIDType::TYPECONST); 439 + public function getPHIDType() { 440 + return PhabricatorCalendarEventPHIDType::TYPECONST; 448 441 } 449 442 450 443 public function getMonogram() {