@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.

Assign PHIDs to calendar events

Summary: Ref T4375. We're going to need these for a bunch of infrastructure to work.

Test Plan: Ran migrations, checked DB, used `phid.query`.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T4375

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

+93
+2
resources/sql/autopatches/20140205.cal.2.phid-col.sql
··· 1 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 2 + ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
+22
resources/sql/autopatches/20140205.cal.3.phid-mig.php
··· 1 + <?php 2 + 3 + $table = new PhabricatorCalendarEvent(); 4 + $conn_w = $table->establishConnection('w'); 5 + 6 + echo "Assigning PHIDs to events...\n"; 7 + foreach (new LiskMigrationIterator($table) as $event) { 8 + $id = $event->getID(); 9 + 10 + echo "Updating event {$id}...\n"; 11 + if ($event->getPHID()) { 12 + continue; 13 + } 14 + 15 + queryfx( 16 + $conn_w, 17 + 'UPDATE %T SET phid = %s WHERE id = %d', 18 + $table->getTableName(), 19 + $table->generatePHID(), 20 + $id); 21 + } 22 + echo "Done.\n";
+2
resources/sql/autopatches/20140205.cal.4.phid-key.sql
··· 1 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 2 + ADD UNIQUE KEY `key_phid` (phid);
+2
src/__phutil_library_map__.php
··· 1271 1271 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 1272 1272 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 1273 1273 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 1274 + 'PhabricatorCalendarPHIDTypeEvent' => 'applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php', 1274 1275 'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php', 1275 1276 'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php', 1276 1277 'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php', ··· 3920 3921 'PhabricatorCalendarEventViewController' => 'PhabricatorDashboardController', 3921 3922 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 3922 3923 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 3924 + 'PhabricatorCalendarPHIDTypeEvent' => 'PhabricatorPHIDType', 3923 3925 'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter', 3924 3926 'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase', 3925 3927 'PhabricatorChangesetResponse' => 'AphrontProxyResponse',
+41
src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarPHIDTypeEvent extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'CEVT'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Event'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhabricatorCalendarEvent(); 17 + } 18 + 19 + protected function buildQueryForObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorCalendarEventQuery()) 24 + ->withPHIDs($phids); 25 + } 26 + 27 + public function loadHandles( 28 + PhabricatorHandleQuery $query, 29 + array $handles, 30 + array $objects) { 31 + 32 + foreach ($handles as $phid => $handle) { 33 + $event = $objects[$phid]; 34 + 35 + $id = $event->getID(); 36 + 37 + $handle->setName(pht('Event %d', $id)); 38 + } 39 + } 40 + 41 + }
+13
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
··· 4 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 5 6 6 private $ids; 7 + private $phids; 7 8 private $rangeBegin; 8 9 private $rangeEnd; 9 10 private $invitedPHIDs; ··· 11 12 12 13 public function withIDs(array $ids) { 13 14 $this->ids = $ids; 15 + return $this; 16 + } 17 + 18 + public function withPHIDs(array $phids) { 19 + $this->phids = $phids; 14 20 return $this; 15 21 } 16 22 ··· 53 59 $conn_r, 54 60 'id IN (%Ld)', 55 61 $this->ids); 62 + } 63 + 64 + if ($this->phids) { 65 + $where[] = qsprintf( 66 + $conn_r, 67 + 'phid IN (%Ls)', 68 + $this->phids); 56 69 } 57 70 58 71 if ($this->rangeBegin) {
+11
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 34 34 return $options[$this->status]; 35 35 } 36 36 37 + public function getConfiguration() { 38 + return array( 39 + self::CONFIG_AUX_PHID => true, 40 + ) + parent::getConfiguration(); 41 + } 42 + 43 + public function generatePHID() { 44 + return PhabricatorPHID::generateNewPHID( 45 + PhabricatorCalendarPHIDTypeEvent::TYPECONST); 46 + } 47 + 37 48 public function getTerseSummary(PhabricatorUser $viewer) { 38 49 $until = phabricator_date($this->dateTo, $viewer); 39 50 if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {