From 1e7a71c1bb4d196e2adf0d6ad5959f7ef28dbbcf Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 16 Mar 2009 22:03:33 +1300 Subject: [PATCH] Trap corner case when collection only has a single entry. --- inc/caldav-GET.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inc/caldav-GET.php b/inc/caldav-GET.php index c82ada01..9555f011 100644 --- a/inc/caldav-GET.php +++ b/inc/caldav-GET.php @@ -20,6 +20,8 @@ if ( $request->IsCollection() ) { /** * The CalDAV specification does not define GET on a collection, but typically this is * used as a .ics download for the whole collection, which is what we do also. + * + * @todo Change this to reference the collection_id of the collection at this location. */ $order_clause = ( isset($c->strict_result_ordering) && $c->strict_result_ordering ? " ORDER BY dav_id" : ""); $qry = new PgQuery( "SELECT caldav_data, class, caldav_type, calendar_item.user_no, logged_user FROM caldav_data INNER JOIN calendar_item USING ( dav_id ) WHERE caldav_data.user_no = ? AND caldav_data.dav_name ~ ? $order_clause", $request->user_no, $request->path.'[^/]+$'); @@ -31,7 +33,7 @@ else { if ( !$qry->Exec("GET") ) { $request->DoResponse( 500, translate("Database Error") ); } -else if ( $qry->rows == 1 ) { +else if ( $qry->rows == 1 && ! $request->IsCollection() ) { $event = $qry->Fetch(); /** Default deny... */