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

Provide a standalone `bin/calendar reload ...` workflow for testing/debugging

Summary:
Ref T11801. This makes testing/debugging a little easier.

Also fix some inconsistencies with `importAuthorPHID` handling -- it should be the import's author PHID in all cases, so we update imported events properly.

Test Plan: Imported a French holiday with `bin/calendar reload ...`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11801

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

+80 -3
+2
src/__phutil_library_map__.php
··· 2157 2157 'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php', 2158 2158 'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php', 2159 2159 'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php', 2160 + 'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php', 2160 2161 'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php', 2161 2162 'PhabricatorCalendarNotification' => 'applications/calendar/storage/PhabricatorCalendarNotification.php', 2162 2163 'PhabricatorCalendarNotificationEngine' => 'applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php', ··· 7025 7026 'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType', 7026 7027 'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController', 7027 7028 'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow', 7029 + 'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow', 7028 7030 'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow', 7029 7031 'PhabricatorCalendarNotification' => 'PhabricatorCalendarDAO', 7030 7032 'PhabricatorCalendarNotificationEngine' => 'Phobject',
+2 -2
src/applications/calendar/import/PhabricatorCalendarImportEngine.php
··· 199 199 if ($node_map) { 200 200 $events = id(new PhabricatorCalendarEventQuery()) 201 201 ->setViewer($viewer) 202 - ->withImportAuthorPHIDs(array($viewer->getPHID())) 202 + ->withImportAuthorPHIDs(array($import->getAuthorPHID())) 203 203 ->withImportUIDs(array_keys($node_map)) 204 204 ->execute(); 205 205 $events = mpull($events, null, 'getImportUID'); ··· 218 218 } 219 219 220 220 $event 221 - ->setImportAuthorPHID($viewer->getPHID()) 221 + ->setImportAuthorPHID($import->getAuthorPHID()) 222 222 ->setImportSourcePHID($import->getPHID()) 223 223 ->setImportUID($full_uid) 224 224 ->attachImportSource($import);
+68
src/applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarManagementReloadWorkflow 4 + extends PhabricatorCalendarManagementWorkflow { 5 + 6 + protected function didConstruct() { 7 + $this 8 + ->setName('reload') 9 + ->setExamples('**reload** [options] __id__ ...') 10 + ->setSynopsis( 11 + pht( 12 + 'Reload event imports from the command line. Useful for '. 13 + 'testing and debugging importers.')) 14 + ->setArguments( 15 + array( 16 + array( 17 + 'name' => 'ids', 18 + 'wildcard' => true, 19 + 'help' => pht('List of import IDs to reload.'), 20 + ), 21 + )); 22 + } 23 + 24 + public function execute(PhutilArgumentParser $args) { 25 + $viewer = $this->getViewer(); 26 + 27 + $ids = $args->getArg('ids'); 28 + if (!$ids) { 29 + throw new PhutilArgumentUsageException( 30 + pht('Specify at least one import ID to reload.')); 31 + } 32 + 33 + $imports = id(new PhabricatorCalendarImportQuery()) 34 + ->setViewer($viewer) 35 + ->withIDs($ids) 36 + ->execute(); 37 + $imports = mpull($imports, null, 'getID'); 38 + foreach ($ids as $id) { 39 + if (empty($imports[$id])) { 40 + throw new PhutilArgumentUsageException( 41 + pht( 42 + 'Unable to load Calendar import with ID "%s".', 43 + $id)); 44 + } 45 + } 46 + 47 + $imports = array_select_keys($imports, $ids); 48 + 49 + foreach ($imports as $import) { 50 + echo tsprintf( 51 + "%s\n", 52 + pht( 53 + 'Importing "%s"...', 54 + $import->getDisplayName())); 55 + 56 + $engine = $import->getEngine(); 57 + 58 + $engine->importEventsFromSource($viewer, $import, false); 59 + } 60 + 61 + echo tsprintf( 62 + "%s\n", 63 + pht('Done.')); 64 + 65 + return 0; 66 + } 67 + 68 + }
+8 -1
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 75 75 $now); 76 76 list($datetime_start, $datetime_end) = $datetime_defaults; 77 77 78 + // When importing events from a context like "bin/calendar reload", we may 79 + // be acting as the omnipotent user. 80 + $host_phid = $actor->getPHID(); 81 + if (!$host_phid) { 82 + $host_phid = $app->getPHID(); 83 + } 84 + 78 85 return id(new PhabricatorCalendarEvent()) 79 86 ->setDescription('') 80 - ->setHostPHID($actor->getPHID()) 87 + ->setHostPHID($host_phid) 81 88 ->setIsCancelled(0) 82 89 ->setIsAllDay(0) 83 90 ->setIsStub(0)