[Pkg-owncloud-commits] [php-sabre-vobject] 25/38: Throw exception when there are no recurrence instances.

David Prévot taffit at moszumanska.debian.org
Tue Sep 23 03:10:23 UTC 2014


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

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

commit c1912258fffb42ca07a89471e58f66d402de7226
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Wed Sep 17 19:39:11 2014 +0100

    Throw exception when there are no recurrence instances.
    
    Closes #131
---
 ChangeLog.md                                          |  2 ++
 lib/Recur/EventIterator.php                           |  3 +++
 lib/Recur/NoInstancesException.php                    | 18 ++++++++++++++++++
 tests/VObject/Recur/EventIterator/NoInstancesTest.php | 12 +++---------
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 55c7530..ee6a9ac 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -13,6 +13,8 @@ ChangeLog
 * #123: Added `SUMMARY` to iTip messages.
 * #130: Incorrect validation rules for `RELATED` (should be `RELATED-TO`).
 * #128: `ATTACH` in iCalendar is `URI` by default, not `BINARY`.
+* #131: RRULE that doesn't provide a single valid instance now throws an
+  exception.
 
 3.3.1 (2014-08-18)
 ------------------
diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php
index 8e69e24..2ea55a4 100644
--- a/lib/Recur/EventIterator.php
+++ b/lib/Recur/EventIterator.php
@@ -176,6 +176,9 @@ class EventIterator implements \Iterator {
         }
 
         $this->rewind();
+        if (!$this->valid()) {
+            throw new NoInstancesException('This recurrence rule does not generate any valid instances');
+        }
 
     }
 
diff --git a/lib/Recur/NoInstancesException.php b/lib/Recur/NoInstancesException.php
new file mode 100644
index 0000000..084bdc1
--- /dev/null
+++ b/lib/Recur/NoInstancesException.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Sabre\VObject\Recur;
+
+use Exception;
+
+/**
+ * This exception gets thrown when a recurrence iterator produces 0 instances.
+ *
+ * This may happen when every occurence in a rrule is also in EXDATE.
+ *
+ * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved.
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class NoInstancesException extends Exception {
+
+}
diff --git a/tests/VObject/Recur/EventIterator/NoInstancesTest.php b/tests/VObject/Recur/EventIterator/NoInstancesTest.php
index e6c450f..81c8ac9 100644
--- a/tests/VObject/Recur/EventIterator/NoInstancesTest.php
+++ b/tests/VObject/Recur/EventIterator/NoInstancesTest.php
@@ -7,6 +7,9 @@ use
 
 class IssueEXDATETest extends \PHPUnit_Framework_TestCase {
 
+    /**
+     * @expectedException \Sabre\VObject\Recur\NoInstancesException
+     */
     function testRecurrence() {
 
         $input = <<<ICS
@@ -32,15 +35,6 @@ ICS;
 
         $it = new EventIterator($vcal, 'foo');
 
-        $end = $it->getDtEnd();
-
-        while($it->valid()) {
-            $end = $it->getDtEnd();
-            $it->next();
-        }
-
-        $end->getTimeStamp();
-
     }
 
 }

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