From 4e77e27fe773a22f1e721ae18f2f4a95a85cccf0 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Wed, 18 Mar 2015 00:45:34 -0400 Subject: [PATCH] Perform this check in the handler. --- kronolith/lib/Api.php | 4 ---- kronolith/lib/Icalendar/Handler/Base.php | 7 ++++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index f376d1d5c83..a5cfeb82899 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -808,10 +808,6 @@ public function import($content, $contentType, $calendar = null) $iCal->addComponent($content); } - $components = $iCal->getComponents(); - if (count($components) == 0) { - throw new Kronolith_Exception(_("No iCalendar data was found.")); - } $ical_importer = new Kronolith_Icalendar_Handler_Base($ical, $kronolith_driver); return $ical_importer->process(); diff --git a/kronolith/lib/Icalendar/Handler/Base.php b/kronolith/lib/Icalendar/Handler/Base.php index cc5a833fd7c..0456312c64d 100644 --- a/kronolith/lib/Icalendar/Handler/Base.php +++ b/kronolith/lib/Icalendar/Handler/Base.php @@ -68,11 +68,16 @@ public function process() * Process the iCalendar data. * * @return array A hash of UID => id. + * @throws Kronolith_Exception */ protected function _process() { $ids = array(); - foreach ($this->_iCal->getComponents() as $component) { + $components = $this->_iCal->getComponents(); + if (count($components) == 0) { + throw new Kronolith_Exception(_("No iCalendar data was found.")); + } + foreach ($components as $component) { if (!$this->_preSave($component)) { continue; }