From c3970f3be2e5018305d8536a35ccad7f27831065 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Tue, 7 Feb 2023 00:45:45 +1300 Subject: [PATCH] Fix RRULE for BYHOUR, BYMINUTE and BYSECOND Closes #283. --- ChangeLog | 3 ++ inc/RRule.php | 6 +-- .../regression-suite/2550-RRULE-PUT.result | 46 +++++++++++++++++++ .../regression-suite/2550-RRULE-PUT.test | 45 ++++++++++++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 testing/tests/regression-suite/2550-RRULE-PUT.result create mode 100644 testing/tests/regression-suite/2550-RRULE-PUT.test diff --git a/ChangeLog b/ChangeLog index 0de9305d..47eb85ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2022-02-07 Andrew Ruthven + * Fix Reccurrence Rules using BYHOUR, BYMINUTE and BYSECOND. + 2022-12-18 Andrew Ruthven * Numerous fixes for PHP 8.2 * Convert RRULE expansion loop limits, and make it configurable to resolve diff --git a/inc/RRule.php b/inc/RRule.php index 64515159..0f55c1d6 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -1080,7 +1080,7 @@ class RepeatRule { $instances = $this->current_set; $this->current_set = array(); foreach( $instances AS $k => $instance ) { - foreach( $this->bymonth AS $k => $month ) { + foreach( $this->byhour AS $k => $hour ) { $this->current_set[] = $this->date_mask( clone($instance), null, null, null, $hour, null, null); } } @@ -1090,7 +1090,7 @@ class RepeatRule { $instances = $this->current_set; $this->current_set = array(); foreach( $instances AS $k => $instance ) { - foreach( $this->bymonth AS $k => $month ) { + foreach( $this->byminute AS $k => $minute ) { $this->current_set[] = $this->date_mask( clone($instance), null, null, null, null, $minute, null); } } @@ -1100,7 +1100,7 @@ class RepeatRule { $instances = $this->current_set; $this->current_set = array(); foreach( $instances AS $k => $instance ) { - foreach( $this->bymonth AS $k => $second ) { + foreach( $this->bysecond AS $k => $second ) { $this->current_set[] = $this->date_mask( clone($instance), null, null, null, null, null, $second); } } diff --git a/testing/tests/regression-suite/2550-RRULE-PUT.result b/testing/tests/regression-suite/2550-RRULE-PUT.result new file mode 100644 index 00000000..f065d393 --- /dev/null +++ b/testing/tests/regression-suite/2550-RRULE-PUT.result @@ -0,0 +1,46 @@ +HTTP/1.1 201 Created +Date: Dow, 01 Jan 2000 00:00:00 GMT +DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule +DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy +ETag: "56c69ee579af9ef1ae32edaeac9d7e26" +Content-Length: 0 +Content-Type: text/plain; charset="utf-8" + + + CalDAV Data: >BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Example Corp.//CalDAV Client//EN +BEGIN:VTODO +UID:takeoutthethrash +DTSTAMP:20221013T151313Z +DTSTART:20221017T065500Z +STATUS:NEEDS-ACTION +DURATION:PT10M +SUMMARY:Take out the thrash before the collectors come. +RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3 +CATEGORIES:CHORE +PRIORITY:3 +END:VTODO +END:VCALENDAR +< + caldav_type: >VTODO< + class: >PUBLIC< + dav_etag: >56c69ee579af9ef1ae32edaeac9d7e26< + description: >NULL< + dtend: >2022-10-17 20:05:00+13< + dtstamp: >2022-10-13 15:13:13< + dtstart: >2022-10-17 19:55:00+13< + due: >NULL< + location: >NULL< + logged_user: >10< + percent_complete: >NULL< + priority: >3< + rrule: >FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3< + status: >NEEDS-ACTION< + summary: >Take out the thrash before the collectors come.< + transp: >NULL< + uid: >takeoutthethrash< + url: >NULL< + user_no: >10< + ~ Modified Now: >0< + diff --git a/testing/tests/regression-suite/2550-RRULE-PUT.test b/testing/tests/regression-suite/2550-RRULE-PUT.test new file mode 100644 index 00000000..bb54e3ae --- /dev/null +++ b/testing/tests/regression-suite/2550-RRULE-PUT.test @@ -0,0 +1,45 @@ +# +# PUT a fancy RRULE +# +# To test https://gitlab.com/davical-project/davical/-/issues/283 +# +TYPE=PUT +URL=http://regression.host/caldav.php/user1/home/takeoutthethrash.ics +HEADER=User-Agent: DAViCal/1.12 +HEADER=Accept: text/xml,application/xml +HEADER=Content-Type: text/calendar; charset=utf-8 + +HEAD + + +BEGINDATA +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Example Corp.//CalDAV Client//EN +BEGIN:VTODO +UID:takeoutthethrash +DTSTAMP:20221013T151313Z +DTSTART:20221017T065500Z +STATUS:NEEDS-ACTION +DURATION:PT10M +SUMMARY:Take out the thrash before the collectors come. +RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=55;COUNT=3 +CATEGORIES:CHORE +PRIORITY:3 +END:VTODO +END:VCALENDAR +ENDDATA + + +QUERY +SELECT caldav_data.user_no, caldav_data.dav_etag, caldav_type, logged_user, + uid, dtstamp, dtstart, dtend, due, summary, location, + description, priority, class, transp, rrule, url, + percent_complete, status, + caldav_data AS " CalDAV Data", + ((current_timestamp AT TIME ZONE 'GMT' - calendar_item.last_modified) < '2 seconds'::interval) AS "~ Modified Now" +FROM caldav_data JOIN calendar_item USING(dav_name) +WHERE caldav_data.dav_name = +'/user1/home/takeoutthethrash.ics'; +ENDQUERY +