diff --git a/inc/DAVResource.php b/inc/DAVResource.php index 0cb1f7a3..7b21c3d5 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -148,8 +148,11 @@ class DAVResource * @param mixed $parameters If null, an empty Resourced is created. * If it is an object then it is expected to be a record that was * read elsewhere. + * @param object $prefetched_collection If provided, the internal collection + * field of the resource is populated with the given data, so it does not need + * to be queried again later */ - function __construct( $parameters = null ) { + function __construct( $parameters = null, DAVResource $prefetched_collection = null ) { $this->exists = null; $this->bound_from = null; $this->dav_name = null; @@ -172,6 +175,11 @@ class DAVResource $this->_is_external = false; $this->_is_addressbook = false; $this->_is_proxy_resource = false; + + if ( isset($prefetched_collection) ) { + $this->collection = $prefetched_collection; + } + if ( isset($parameters) && is_object($parameters) ) { $this->FromRow($parameters); } diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php index f0d22ea5..f1f412c6 100644 --- a/inc/caldav-REPORT-sync-collection.php +++ b/inc/caldav-REPORT-sync-collection.php @@ -144,7 +144,7 @@ EOSQL; else if ( $object->sync_status == 201 && $first_status == 404 ) { // ... Delete ... Create ... is indicated as a create, but don't forget we started with a delete array_pop($responses); - $dav_resource = new DAVResource($object); + $dav_resource = new DAVResource($object, $collection); $resultset = $dav_resource->GetPropStat($proplist,$reply); array_unshift($resultset, new XMLElement( 'href', ConstructURL($object->dav_name))); $responses[] = new XMLElement( 'response', $resultset ); @@ -167,7 +167,7 @@ EOSQL; $first_status = 404; } else { - $dav_resource = new DAVResource($object); + $dav_resource = new DAVResource($object, $collection); $resultset = $dav_resource->GetPropStat($proplist,$reply); array_unshift($resultset, new XMLElement( 'href', ConstructURL($object->dav_name))); $first_status = $object->sync_status;