[Pkg-owncloud-commits] [php-sabre-vobject] 03/43: When expanding, ignore events that are recurring but have 0 valid recurrence instances.

David Prévot taffit at moszumanska.debian.org
Sat Jan 10 14:20:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit f7e4977c72badabfee131def7c703e5bab7ee60d
Author: Evert Pot <me at evertpot.com>
Date:   Mon Dec 8 18:33:22 2014 -0500

    When expanding, ignore events that are recurring but have 0 valid
    recurrence instances.
    
    Fixes #168.
---
 ChangeLog.md                              |  9 +++++++++
 lib/Component/VCalendar.php               | 14 +++++++++++++-
 lib/Version.php                           |  2 +-
 tests/VObject/Component/VCalendarTest.php | 22 ++++++++++++++++++++++
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 6dcc337..3453519 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,6 +1,13 @@
 ChangeLog
 =========
 
+3.3.5 (2014-??-??)
+------------------
+
+* #168: Expanding calendars now removes objects with recurrence rules that
+  don't have a valid recurrence instance.
+
+
 3.3.4 (2014-11-19)
 ------------------
 
@@ -33,6 +40,7 @@ ChangeLog
 * Support for "Line Islands Standard Time" windows timezone.
 * #154: Correctly work around vCard parameters that have a value but no name.
 
+
 3.3.2 (2014-09-19)
 ------------------
 
@@ -54,6 +62,7 @@ ChangeLog
   declined earlier will no longer generate another reply.
 * #125: Send CANCEL messages when ORGANIZER property gets deleted.
 
+
 3.3.1 (2014-08-18)
 ------------------
 
diff --git a/lib/Component/VCalendar.php b/lib/Component/VCalendar.php
index 8704d33..56c07cf 100644
--- a/lib/Component/VCalendar.php
+++ b/lib/Component/VCalendar.php
@@ -7,6 +7,7 @@ use DateTimeZone;
 use Sabre\VObject;
 use Sabre\VObject\Component;
 use Sabre\VObject\Recur\EventIterator;
+use Sabre\VObject\Recur\NoInstancesException;
 
 /**
  * The VCalendar component
@@ -268,12 +269,22 @@ class VCalendar extends VObject\Document {
                 continue;
             }
 
+
+
             $uid = (string)$vevent->uid;
             if (!$uid) {
                 throw new \LogicException('Event did not have a UID!');
             }
 
-            $it = new EventIterator($this, $vevent->uid, $timeZone);
+            try {
+                $it = new EventIterator($this, $vevent->uid, $timeZone);
+            } catch (NoInstancesException $e) {
+                // This event is recurring, but it doesn't have a single
+                // instance. We are skipping this event from the output
+                // entirely.
+                unset($this->children[$key]);
+                continue;
+            }
             $it->fastForward($start);
 
             while($it->valid() && $it->getDTStart() < $end) {
@@ -286,6 +297,7 @@ class VCalendar extends VObject\Document {
                 $it->next();
 
             }
+
             unset($this->children[$key]);
 
         }
diff --git a/lib/Version.php b/lib/Version.php
index 1a5ecbb..dd74a6c 100644
--- a/lib/Version.php
+++ b/lib/Version.php
@@ -14,6 +14,6 @@ class Version {
     /**
      * Full version number
      */
-    const VERSION = '3.3.4';
+    const VERSION = '3.3.5';
 
 }
diff --git a/tests/VObject/Component/VCalendarTest.php b/tests/VObject/Component/VCalendarTest.php
index 2f4d21c..31f1787 100644
--- a/tests/VObject/Component/VCalendarTest.php
+++ b/tests/VObject/Component/VCalendarTest.php
@@ -268,6 +268,28 @@ ICS;
 
         $tests[] = array($input, $output, 'America/Argentina/Buenos_Aires', '2014-01-01', '2015-01-01');
 
+        // Recurrence rule with no valid instances
+        $input = 'BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+VERSION:2.0
+BEGIN:VEVENT
+UID:bla6
+SUMMARY:Testing RRule3
+DTSTART:20111125T120000Z
+DTEND:20111125T130000Z
+RRULE:FREQ=WEEKLY;COUNT=1
+EXDATE:20111125T120000Z
+END:VEVENT
+END:VCALENDAR
+';
+
+        $output = 'BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+VERSION:2.0
+END:VCALENDAR
+';
+
+        $tests[] = array($input, $output);
         return $tests;
 
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list