Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13992453
D16721.id40272.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D16721.id40272.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
@@ -2118,6 +2118,7 @@
'PhabricatorCalendarImportEpochLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportEpochLogType.php',
'PhabricatorCalendarImportFrequencyLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportFrequencyLogType.php',
'PhabricatorCalendarImportICSFileTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportICSFileTransaction.php',
+ 'PhabricatorCalendarImportICSLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportICSLogType.php',
'PhabricatorCalendarImportIgnoredNodeLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportIgnoredNodeLogType.php',
'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php',
'PhabricatorCalendarImportLog' => 'applications/calendar/storage/PhabricatorCalendarImportLog.php',
@@ -6952,6 +6953,7 @@
'PhabricatorCalendarImportEpochLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportFrequencyLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportICSFileTransaction' => 'PhabricatorCalendarImportTransactionType',
+ 'PhabricatorCalendarImportICSLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportIgnoredNodeLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportListController' => 'PhabricatorCalendarController',
'PhabricatorCalendarImportLog' => array(
diff --git a/src/applications/calendar/import/PhabricatorCalendarICSImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarICSImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarICSImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarICSImportEngine.php
@@ -62,9 +62,25 @@
$data = $file->loadFileData();
- $parser = id(new PhutilICSParser());
-
- $document = $parser->parseICSData($data);
+ $parser = new PhutilICSParser();
+
+ try {
+ $document = $parser->parseICSData($data);
+ } catch (PhutilICSParserException $ex) {
+ // TODO: In theory, it would be nice to store these in a fully abstract
+ // form so they can be translated at display time. As-is, we'll store the
+ // error messages in whatever language we were using when the parser
+ // failure occurred.
+
+ $import->newLogMessage(
+ PhabricatorCalendarImportICSLogType::LOGTYPE,
+ array(
+ 'ics.code' => $ex->getParserFailureCode(),
+ 'ics.message' => $ex->getMessage(),
+ ));
+
+ $document = null;
+ }
return $this->importEventDocument($viewer, $import, $document);
}
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
@@ -42,24 +42,26 @@
final protected function importEventDocument(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import,
- PhutilCalendarRootNode $root) {
+ PhutilCalendarRootNode $root = null) {
$event_type = PhutilCalendarEventNode::NODETYPE;
$nodes = array();
- foreach ($root->getChildren() as $document) {
- foreach ($document->getChildren() as $node) {
- $node_type = $node->getNodeType();
- if ($node_type != $event_type) {
- $import->newLogMessage(
- PhabricatorCalendarImportIgnoredNodeLogType::LOGTYPE,
- array(
- 'node.type' => $node_type,
- ));
- continue;
+ if ($root) {
+ foreach ($root->getChildren() as $document) {
+ foreach ($document->getChildren() as $node) {
+ $node_type = $node->getNodeType();
+ if ($node_type != $event_type) {
+ $import->newLogMessage(
+ PhabricatorCalendarImportIgnoredNodeLogType::LOGTYPE,
+ array(
+ 'node.type' => $node_type,
+ ));
+ continue;
+ }
+
+ $nodes[] = $node;
}
-
- $nodes[] = $node;
}
}
diff --git a/src/applications/calendar/importlog/PhabricatorCalendarImportICSLogType.php b/src/applications/calendar/importlog/PhabricatorCalendarImportICSLogType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/importlog/PhabricatorCalendarImportICSLogType.php
@@ -0,0 +1,36 @@
+<?php
+
+final class PhabricatorCalendarImportICSLogType
+ extends PhabricatorCalendarImportLogType {
+
+ const LOGTYPE = 'ics';
+
+ public function getDisplayType(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return pht('ICS Parse Error');
+ }
+
+ public function getDisplayDescription(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return pht(
+ 'Failed to parse ICS file ("%s"): %s',
+ $log->getParameter('ics.code'),
+ $log->getParameter('ics.message'));
+ }
+
+
+ public function getDisplayIcon(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return 'fa-file';
+ }
+
+ public function getDisplayColor(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return 'red';
+ }
+
+}
diff --git a/src/applications/calendar/view/PhabricatorCalendarImportLogView.php b/src/applications/calendar/view/PhabricatorCalendarImportLogView.php
--- a/src/applications/calendar/view/PhabricatorCalendarImportLogView.php
+++ b/src/applications/calendar/view/PhabricatorCalendarImportLogView.php
@@ -48,7 +48,7 @@
: null),
id(new PHUIIconView())->setIcon($icon, $color),
$name,
- $description,
+ phutil_escape_html_newlines($description),
phabricator_datetime($log->getDateCreated(), $viewer),
);
}
@@ -70,12 +70,12 @@
))
->setColumnClasses(
array(
- null,
- null,
- null,
- 'pri',
- 'wide',
- null,
+ 'top',
+ 'top',
+ 'top',
+ 'top pri',
+ 'top wide',
+ 'top',
));
return $table;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 4:46 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6734299
Default Alt Text
D16721.id40272.diff (6 KB)
Attached To
Mode
D16721: When import fails because we can't parse an ICS file, show it nicely
Attached
Detach File
Event Timeline
Log In to Comment