From a79192cc637fb3dd2bd4cd95a5f29e21c9939c7f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 25 Sep 2013 10:27:41 +0000 Subject: [PATCH] fixed not found multiget-report urls where not reported (worked for calendar only before sync-report was introduced) --- .../inc/class.addressbook_groupdav.inc.php | 28 +++++++++++++++++-- calendar/inc/class.calendar_groupdav.inc.php | 27 +++++++++--------- infolog/inc/class.infolog_groupdav.inc.php | 15 ++++++++++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 2fbb59b836..43201f4598 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -185,7 +185,7 @@ class addressbook_groupdav extends groupdav_handler * @param array|boolean $start=false false=return all or array(start,num) * @return array with "files" array with values for keys path and props */ - function &propfind_callback($path,array $filter,$start=false) + function &propfind_callback($path,array $filter,$start=false,$report_not_found_multiget_ids=true) { $starttime = microtime(true); $filter_in = $filter; @@ -208,6 +208,8 @@ class addressbook_groupdav extends groupdav_handler // detect sync-collection report $sync_collection_report = isset($filter[0]) && strpos($filter[0], 'contact_modified>') === 0; + $requested_multiget_ids =& $filter_in[self::$path_attr]; + $files = array(); // we query etag and modified, as LDAP does not have the strong sql etag $cols = array('id','uid','etag','modified','n_fn'); @@ -218,6 +220,11 @@ class addressbook_groupdav extends groupdav_handler { foreach($contacts as &$contact) { + // remove contact from requested multiget ids, to be able to report not found urls + if ($requested_multiget_ids && ($k = array_search($contacts[self::$path_attr], $requested_multiget_ids)) !== false) + { + unset($requested_multiget_ids[$k]); + } // sync-collection report: deleted entry need to be reported without properties if ($contact['tid'] == addressbook_bo::DELETED_TYPE) { @@ -253,7 +260,7 @@ class addressbook_groupdav extends groupdav_handler if ($sync_collection_report) $token_was = $this->sync_collection_token; groupdav_handler::$path_attr = 'id'; groupdav_handler::$path_extension = '.vcf'; - $files = array_merge($files, $this->propfind_callback($path, $accounts_filter)); + $files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false)); groupdav_handler::$path_attr = 'carddav_name'; groupdav_handler::$path_extension = ''; if ($sync_collection_report && $token_was > $this->sync_collection_token) @@ -282,7 +289,7 @@ class addressbook_groupdav extends groupdav_handler { foreach($lists as $list) { - $list['carddav_name'] = $list['list_carddav_name']; + $list[self::$path_attr] = $list['list_carddav_name']; $etag = $list['list_id'].':'.$list['list_etag']; // for all-in-one addressbook, add selected ABs to etag if (isset($filter['owner']) && is_array($filter['owner'])) @@ -303,6 +310,12 @@ class addressbook_groupdav extends groupdav_handler } $files[] = $this->add_resource($path, $list, $props); + // remove list from requested multiget ids, to be able to report not found urls + if ($requested_multiget_ids && ($k = array_search($list[self::$path_attr], $requested_multiget_ids)) !== false) + { + unset($requested_multiget_ids[$k]); + } + if ($sync_collection_report && $this->sync_collection_token < ($ts=$GLOBALS['egw']->db->from_timestamp($list['list_modified']))) { $this->sync_collection_token = $ts; @@ -311,6 +324,15 @@ class addressbook_groupdav extends groupdav_handler } } } + // report not found multiget urls + if ($report_not_found_multiget_ids && $requested_multiget_ids) + { + foreach($requested_multiget_ids as $id) + { + $files[] = array('path' => $path.$id.self::$path_extension); + } + } + if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); return $files; } diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index 1cd8849707..d732515c51 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -264,12 +264,12 @@ class calendar_groupdav extends groupdav_handler $filter['num_rows'] = $start[1]; } $requested_multiget_ids = $filter['query'][self::$path_attr]; + $sync_collection = strpos($filter['query'][0],'cal_modified>') === 0 && $filter['filter'] == 'everything'; $events =& $this->bo->search($filter); + if ($events) { - $sync_collection = strpos($filter['query'][0],'cal_modified>') === 0 && $filter['filter'] == 'everything'; - foreach($events as $event) { // remove event from requested multiget ids, to be able to report not found urls @@ -323,20 +323,21 @@ class calendar_groupdav extends groupdav_handler }*/ $files[] = $this->add_resource($path, $event, $props); } - // report not found multiget urls - if ($requested_multiget_ids) + } + // report not found multiget urls + if ($requested_multiget_ids) + { + foreach($requested_multiget_ids as $id) { - foreach($requested_multiget_ids as $id) - { - $files[] = array('path' => $path.$id.self::$path_extension); - } - } - // sync-collection report --> return modified of last contact as sync-token - if ($sync_collection_report) - { - $this->sync_collection_token = $event['modified']; + $files[] = array('path' => $path.$id.self::$path_extension); } } + // sync-collection report --> return modified of last contact as sync-token + if ($sync_collection_report) + { + $this->sync_collection_token = $event['modified']; + } + if ($this->debug) { error_log(__METHOD__."($path) took ".(microtime(true) - $starttime). diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index 126cb0c105..090d9f60a6 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -254,6 +254,8 @@ class infolog_groupdav extends groupdav_handler $offset = 0; } + $requested_multiget_ids = $filter[self::$path_attr]; + $files = array(); // ToDo: add parameter to only return id & etag $tasks =& $this->bo->search($query); @@ -261,6 +263,11 @@ class infolog_groupdav extends groupdav_handler { foreach($tasks as $task) { + // remove task from requested multiget ids, to be able to report not found urls + if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false) + { + unset($requested_multiget_ids[$k]); + } // sync-collection report: deleted entry need to be reported without properties if ($task['info_status'] == 'deleted') { @@ -281,6 +288,14 @@ class infolog_groupdav extends groupdav_handler $files[] = $this->add_resource($path, $task, $props); } } + // report not found multiget urls + if ($requested_multiget_ids) + { + foreach($requested_multiget_ids as $id) + { + $files[] = array('path' => $path.$id.self::$path_extension); + } + } // sync-collection report --> return modified of last contact as sync-token $sync_collection_report = strpos($task_filter, '+deleted') !== false; if ($sync_collection_report)