MDL-66871 calendar: fix ics importing logic
authorSimey Lameze <simey@moodle.com>
Mon, 16 Dec 2019 00:36:26 +0000 (08:36 +0800)
committerSimey Lameze <simey@moodle.com>
Mon, 6 Jan 2020 01:49:59 +0000 (09:49 +0800)
calendar/lib.php

index 43e9de8..381580e 100644 (file)
@@ -3066,7 +3066,8 @@ function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid
         }
     }
 
-    if (!empty($subscriptionid)) {
+    $existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]);
+    if (!empty($existing)) {
         $eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid');
 
         $icaleventscount = count($icaluuids);