summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/kolab_sync_backend.php9
-rw-r--r--lib/kolab_sync_data.php48
2 files changed, 23 insertions, 34 deletions
diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index b4bd3ca..f11f631 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -789,7 +789,7 @@ class kolab_sync_backend
// get all folders of specified type
$folderdata = $this->folder_meta();
- if (!is_array($folderdata)) {
+ if (!is_array($folderdata) || $id === null) {
return null;
}
@@ -801,10 +801,11 @@ class kolab_sync_backend
continue;
}
- $uid = self::folder_id($folder);
- $this->folder_uids[$folder] = $uid;
+ if ($uid = self::folder_id($folder)) {
+ $this->folder_uids[$folder] = $uid;
+ }
- if ($uid == $id) {
+ if ($uid === $id) {
$name = $folder;
}
}
diff --git a/lib/kolab_sync_data.php b/lib/kolab_sync_data.php
index 3579a12..2e6a1e2 100644
--- a/lib/kolab_sync_data.php
+++ b/lib/kolab_sync_data.php
@@ -375,13 +375,12 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
foreach ($folders as $folderid) {
$foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid);
+ $folder = $this->getFolderObject($foldername);
- if ($foldername === null) {
- continue;
+ if (!$folder || !$folder->valid) {
+ throw new Syncroton_Exception_Status_ItemOperations(Syncroton_Exception_Status_ItemOperations::ITEM_SERVER_ERROR);
}
- $folder = $this->getFolderObject($foldername);
-
// Remove all entries
$folder->delete_all();
@@ -390,13 +389,12 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
$list = $this->listFolders($folderid);
foreach ($list as $folderid => $folder) {
$foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid);
+ $folder = $this->getFolderObject($foldername);
- if ($foldername === null) {
- continue;
+ if (!$folder || !$folder->valid) {
+ throw new Syncroton_Exception_Status_ItemOperations(Syncroton_Exception_Status_ItemOperations::ITEM_SERVER_ERROR);
}
- $folder = $this->getFolderObject($foldername);
-
// Remove all entries
$folder->delete_all();
}
@@ -538,17 +536,12 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
$result = $result_type == self::RESULT_COUNT ? 0 : array();
$found = 0;
- foreach ($folders as $folderid) {
- $foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid);
-
- if ($foldername === null) {
- continue;
- }
+ foreach ($folders as $folder_id) {
+ $foldername = $this->backend->folder_id2name($folder_id, $this->device->deviceid);
+ $folder = $this->getFolderObject($foldername);
- $folder = $this->getFolderObject($foldername);
-
- if (!$folder) {
- continue;
+ if (!$folder || !$folder->valid) {
+ throw new Syncroton_Exception_Status(Syncroton_Exception_Status::SERVER_ERROR);
}
$found++;
@@ -753,14 +746,9 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
foreach ($folders as $folderid) {
$foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid);
+ $folder = $this->getFolderObject($foldername);
- if ($foldername === null) {
- continue;
- }
-
- $folder = $this->getFolderObject($foldername);
-
- if ($folder && ($object = $folder->get_object($entryid))) {
+ if ($folder && $folder->valid && ($object = $folder->get_object($entryid))) {
$object['_folderid'] = $folderid;
return $object;
@@ -786,7 +774,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
$foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid);
$folder = $this->getFolderObject($foldername);
- if ($folder && $folder->save($data)) {
+ if ($folder && $folder->valid && $folder->save($data)) {
return $data;
}
}
@@ -801,7 +789,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
if ($object) {
$folder = $this->getFolderObject($object['_mailbox']);
- if ($folder && $folder->save($data)) {
+ if ($folder && $folder->valid && $folder->save($data)) {
return $data;
}
}
@@ -816,7 +804,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
if ($object) {
$folder = $this->getFolderObject($object['_mailbox']);
- return $folder && $folder->delete($entryid);
+ return $folder && $folder->valid && $folder->delete($entryid);
}
// object doesn't exist, confirm deletion
@@ -891,12 +879,12 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
*/
protected function getFolderObject($name)
{
- if ($name === null) {
+ if ($name === null || $name === '') {
return null;
}
if (!isset($this->folders[$name])) {
- $this->folders[$name] = kolab_storage::get_folder($name);
+ $this->folders[$name] = kolab_storage::get_folder($name, $this->modelName);
}
return $this->folders[$name];