From 48efbb272b4a80415bf4af81f309638f1cfc0ee1 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Mon, 12 Nov 2018 19:32:34 +1300 Subject: [PATCH] Fix Fatal PHP Error if Depth is more than 1. Merge request was proposed by xhess on GitLab, but the commit had no content. I've solved it, possibly the same way. For the initial commit: Executing the second example at https://wiki.davical.org/index.php?title=PROPFIND The "Depth: 2" header is the problem. Setting the depth header larger than 1 causes the function "compare_val_with_re" to be defined again. Now checking if the function has already been defined fixes the problem. --- inc/caldav-PROPFIND.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index 21a28e77..887ec5de 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -105,7 +105,9 @@ function get_collection_contents( $depth, $collection, $parent_path = null ) { global $c, $session, $request, $reply, $property_list; // for http header comparison - function compare_val_with_re($val, $re){ return preg_match($re, $val)===1 ? 0 : 1; } + if (! function_exists ('compare_val_with_re') ) { + function compare_val_with_re($val, $re){ return preg_match($re, $val)===1 ? 0 : 1; } + } $bound_from = $collection->bound_from(); $bound_to = $collection->dav_name();