From 11cb3326031c04ebffe1bc3fdb974d665afeec6a Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 11 Apr 2012 00:39:07 +1200 Subject: [PATCH] Make sure we increment the sync-token on PUT / DELETE. --- inc/caldav-DELETE.php | 8 +++++--- inc/caldav-PUT-functions.php | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/caldav-DELETE.php b/inc/caldav-DELETE.php index db1be0bf..af539d5a 100644 --- a/inc/caldav-DELETE.php +++ b/inc/caldav-DELETE.php @@ -80,20 +80,22 @@ else { $cache = getCacheInstance(); $myLock = $cache->acquireLock('collection-'.$dav_resource->parent_path()); + $collection_id = $dav_resource->GetProperty('collection_id'); $params = array( ':dav_id' => $dav_resource->resource_id() ); - if ( $qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE dav_id = :dav_id", $params ) + if ( $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')') + && $qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE dav_id = :dav_id", $params ) && $qry->QDo("DELETE FROM property WHERE dav_name = (SELECT dav_name FROM caldav_data WHERE dav_id = :dav_id)", $params ) && $qry->QDo("DELETE FROM locks WHERE dav_name = (SELECT dav_name FROM caldav_data WHERE dav_id = :dav_id)", $params ) && $qry->QDo("DELETE FROM caldav_data WHERE dav_id = :dav_id", $params ) ) { if ( function_exists('log_caldav_action') ) { - log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $dav_resource->GetProperty('collection_id'), $request->path ); + log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path ); } $qry->Commit(); @dbg_error_log( "DELETE", "DELETE: User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path); if ( function_exists('post_commit_action') ) { - post_commit_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $dav_resource->GetProperty('collection_id'), $request->path ); + post_commit_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path ); } $cache->delete( 'collection-'.$dav_resource->parent_path(), null ); diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index 3e824695..98414fa8 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -803,6 +803,9 @@ UPDATE calendar_item SET user_no=:user_no, dav_etag=:etag, uid=:uid, dtstamp=:dt EOSQL; $last_olson = ''; + if ( count($resources) > 0 ) + $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')'); + foreach( $resources AS $uid => $resource ) { /** Construct the VCALENDAR data */ @@ -1269,6 +1272,7 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle } + $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')'); $calitem_params[':tzid'] = $tzid; $calitem_params[':uid'] = $first->GetPValue('UID');