From 2a202c77a298bcfe0c034e8e8e6d725232b81b58 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 22 Jun 2016 22:41:05 +0100 Subject: [PATCH] Ensuring we delete vigorously from the cache for DELETE is ++important! --- inc/caldav-DELETE.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/caldav-DELETE.php b/inc/caldav-DELETE.php index 41e895cc..f577c5ff 100644 --- a/inc/caldav-DELETE.php +++ b/inc/caldav-DELETE.php @@ -45,6 +45,7 @@ function delete_collection( $id ) { if ( !$dav_resource->Exists() )$request->DoResponse( 404 ); if ( ! ( $dav_resource->resource_id() > 0 ) ) { + @dbg_error_log( "DELETE", ": failed: User: %d, ETag: %s, Path: %s, ResourceID: %d", $session->user_no, $request->etag_if_match, $request->path, $dav_resource->resource_id()); $request->DoResponse( 403 ); } @@ -52,11 +53,16 @@ $qry = new AwlQuery(); $qry->Begin(); if ( $dav_resource->IsCollection() ) { + $cache = getCacheInstance(); + $myLock = $cache->acquireLock('collection-'.$dav_resource->parent_path()); if ( $dav_resource->IsBinding() ) { $params = array( ':dav_name' => $dav_resource->dav_name() ); if ( $qry->QDo("DELETE FROM dav_binding WHERE dav_name = :dav_name", $params ) && $qry->Commit() ) { + $cache->delete( 'collection-'.$dav_resource->dav_name(), null ); + $cache->delete( 'collection-'.$dav_resource->parent_path(), null ); + $cache->releaseLock($myLock); @dbg_error_log( "DELETE", "DELETE: Binding: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path); $request->DoResponse( 204 ); } @@ -64,11 +70,13 @@ if ( $dav_resource->IsCollection() ) { else { if ( delete_collection( $dav_resource->resource_id() ) && $qry->Commit() ) { // Uncache anything to do with the collection - $cache = getCacheInstance(); $cache->delete( 'collection-'.$dav_resource->dav_name(), null ); + $cache->delete( 'collection-'.$dav_resource->parent_path(), null ); + $cache->releaseLock($myLock); $request->DoResponse( 204 ); } } + $cache->releaseLock($myLock); } else { if ( isset($request->etag_if_match) && $request->etag_if_match != $dav_resource->unique_tag() && $request->etag_if_match != "*" ) {