Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15427482
D16814.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D16814.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2157,6 +2157,7 @@
'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php',
'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php',
'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php',
+ 'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php',
'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php',
'PhabricatorCalendarNotification' => 'applications/calendar/storage/PhabricatorCalendarNotification.php',
'PhabricatorCalendarNotificationEngine' => 'applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php',
@@ -7025,6 +7026,7 @@
'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController',
'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow',
+ 'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow',
'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorCalendarNotification' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarNotificationEngine' => 'Phobject',
diff --git a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
@@ -199,7 +199,7 @@
if ($node_map) {
$events = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer)
- ->withImportAuthorPHIDs(array($viewer->getPHID()))
+ ->withImportAuthorPHIDs(array($import->getAuthorPHID()))
->withImportUIDs(array_keys($node_map))
->execute();
$events = mpull($events, null, 'getImportUID');
@@ -218,7 +218,7 @@
}
$event
- ->setImportAuthorPHID($viewer->getPHID())
+ ->setImportAuthorPHID($import->getAuthorPHID())
->setImportSourcePHID($import->getPHID())
->setImportUID($full_uid)
->attachImportSource($import);
diff --git a/src/applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php b/src/applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php
@@ -0,0 +1,68 @@
+<?php
+
+final class PhabricatorCalendarManagementReloadWorkflow
+ extends PhabricatorCalendarManagementWorkflow {
+
+ protected function didConstruct() {
+ $this
+ ->setName('reload')
+ ->setExamples('**reload** [options] __id__ ...')
+ ->setSynopsis(
+ pht(
+ 'Reload event imports from the command line. Useful for '.
+ 'testing and debugging importers.'))
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'ids',
+ 'wildcard' => true,
+ 'help' => pht('List of import IDs to reload.'),
+ ),
+ ));
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $viewer = $this->getViewer();
+
+ $ids = $args->getArg('ids');
+ if (!$ids) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify at least one import ID to reload.'));
+ }
+
+ $imports = id(new PhabricatorCalendarImportQuery())
+ ->setViewer($viewer)
+ ->withIDs($ids)
+ ->execute();
+ $imports = mpull($imports, null, 'getID');
+ foreach ($ids as $id) {
+ if (empty($imports[$id])) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Unable to load Calendar import with ID "%s".',
+ $id));
+ }
+ }
+
+ $imports = array_select_keys($imports, $ids);
+
+ foreach ($imports as $import) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Importing "%s"...',
+ $import->getDisplayName()));
+
+ $engine = $import->getEngine();
+
+ $engine->importEventsFromSource($viewer, $import, false);
+ }
+
+ echo tsprintf(
+ "%s\n",
+ pht('Done.'));
+
+ return 0;
+ }
+
+}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -75,9 +75,16 @@
$now);
list($datetime_start, $datetime_end) = $datetime_defaults;
+ // When importing events from a context like "bin/calendar reload", we may
+ // be acting as the omnipotent user.
+ $host_phid = $actor->getPHID();
+ if (!$host_phid) {
+ $host_phid = $app->getPHID();
+ }
+
return id(new PhabricatorCalendarEvent())
->setDescription('')
- ->setHostPHID($actor->getPHID())
+ ->setHostPHID($host_phid)
->setIsCancelled(0)
->setIsAllDay(0)
->setIsStub(0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 2:37 PM (22 h, 9 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387831
Default Alt Text
D16814.diff (5 KB)
Attached To
Mode
D16814: Provide a standalone `bin/calendar reload ...` workflow for testing/debugging
Attached
Detach File
Event Timeline
Log In to Comment