Hi,
I have two calendars, the standard DAViCal internal calendar plus an
external calendar, which is bound to a collection under the same parent.
$c->get_includes_subcollections is to true.
Reading the events from the parent, delivers all events from both
calendars. Fine!
Reading free/busy from the parent, only takes the events of the internal
calendar into account. This is not what I expect to receive.
From my observations, the reason seems to be the SQL to read the
relevant events. The following patch seems to correct the problem for me:
--- inc/freebusy-functions.php.ori 2019-01-30
20:52:46.000000000 +0100
+++ inc/freebusy-functions.php 2019-08-07 10:44:18.340251126 +0200
@@ -19,7 +19,7 @@
$request->DoResponse( 400, 'All valid freebusy requests MUST
contain a time-range filter' );
}
$params = array( ':path_match' => $path_match, ':start' =>
$range_start->UTC(), ':end' => $range_end->UTC() );
- $where = ' WHERE caldav_data.dav_name ~ :path_match ';
+ $where = ' WHERE (caldav_data.dav_name ~ :path_match OR
dav_binding.dav_name ~ :path_match) ';
$where .= "AND (";
$where .= " (calendar_item.first_instance_start <= :end AND
(:start <= calendar_item.last_instance_end OR
calendar_item.last_instance_end IS NULL)) ";
$where .= " OR (calendar_item.first_instance_start IS NULL AND
rrule_event_overlaps( dtstart, dtend, rrule, :start, :end)) ";
@@ -41,6 +41,7 @@
$sql .= "collection.timezone AS collection_tzid ";
$sql .= 'FROM caldav_data INNER JOIN calendar_item
USING(dav_id,user_no,dav_name,collection_id) ';
$sql .= 'INNER JOIN collection USING(collection_id)';
+ $sql .= 'LEFT OUTER JOIN dav_binding ON collection.collection_id
= dav_binding.bound_source_id';
$sql .= $where;
if ( isset($c->strict_result_ordering) &&
$c->strict_result_ordering ) $sql .= ' ORDER BY dav_id';
$qry = new AwlQuery( $sql, $params );
It adds an outer join to dav_binding and also selects dav_names from there.
Can anyone confirm, that my understanding and my changes are correct?
Regards,
Christopher
I have two calendars, the standard DAViCal internal calendar plus an
external calendar, which is bound to a collection under the same parent.
$c->get_includes_subcollections is to true.
Reading the events from the parent, delivers all events from both
calendars. Fine!
Reading free/busy from the parent, only takes the events of the internal
calendar into account. This is not what I expect to receive.
From my observations, the reason seems to be the SQL to read the
relevant events. The following patch seems to correct the problem for me:
--- inc/freebusy-functions.php.ori 2019-01-30
20:52:46.000000000 +0100
+++ inc/freebusy-functions.php 2019-08-07 10:44:18.340251126 +0200
@@ -19,7 +19,7 @@
$request->DoResponse( 400, 'All valid freebusy requests MUST
contain a time-range filter' );
}
$params = array( ':path_match' => $path_match, ':start' =>
$range_start->UTC(), ':end' => $range_end->UTC() );
- $where = ' WHERE caldav_data.dav_name ~ :path_match ';
+ $where = ' WHERE (caldav_data.dav_name ~ :path_match OR
dav_binding.dav_name ~ :path_match) ';
$where .= "AND (";
$where .= " (calendar_item.first_instance_start <= :end AND
(:start <= calendar_item.last_instance_end OR
calendar_item.last_instance_end IS NULL)) ";
$where .= " OR (calendar_item.first_instance_start IS NULL AND
rrule_event_overlaps( dtstart, dtend, rrule, :start, :end)) ";
@@ -41,6 +41,7 @@
$sql .= "collection.timezone AS collection_tzid ";
$sql .= 'FROM caldav_data INNER JOIN calendar_item
USING(dav_id,user_no,dav_name,collection_id) ';
$sql .= 'INNER JOIN collection USING(collection_id)';
+ $sql .= 'LEFT OUTER JOIN dav_binding ON collection.collection_id
= dav_binding.bound_source_id';
$sql .= $where;
if ( isset($c->strict_result_ordering) &&
$c->strict_result_ordering ) $sql .= ' ORDER BY dav_id';
$qry = new AwlQuery( $sql, $params );
It adds an outer join to dav_binding and also selects dav_names from there.
Can anyone confirm, that my understanding and my changes are correct?
Regards,
Christopher