Sometimes we want the action hook to be post commit.

This adds another hook, and makes log_caldav_action() regular
across both PUT and DELETE (in a transaction), adding post_commit_hook()
as a method with the same signature which is called after the actual
commit, and also matches in both cases.
This commit is contained in:
Andrew McMillan 2012-04-10 23:30:07 +12:00
parent e35db30a0d
commit a34203a7b8
2 changed files with 14 additions and 4 deletions

View File

@ -84,12 +84,18 @@ else {
if ( $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 )
&& $qry->Commit() ) {
&& $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 );
}
$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('log_caldav_action') ) {
log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $dav_resource->GetProperty('collection_id'), $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 );
}
$cache->delete( 'collection-'.$dav_resource->parent_path(), null );
$cache->releaseLock($myLock);
$request->DoResponse( 204 );

View File

@ -1358,6 +1358,10 @@ EOSQL;
$qry->QDo("SELECT write_sync_change( $collection_id, $sync_change, :dav_name)", array(':dav_name' => $path ) );
$qry->Commit();
if ( function_exists('post_commit_action') ) {
post_commit_action( $put_action_type, $first->GetPValue('UID'), $user_no, $collection_id, $path );
}
// Uncache anything to do with the collection
$cache = getCacheInstance();
$cache_ns = 'collection-'.preg_replace( '{/[^/]*$}', '/', $path);