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; }