Commit 1d9e2302 authored by Manfred Kutas's avatar Manfred Kutas

ZP-779 Only use folderid prefix in importer if it is the new int one.

Fix Fetch() in Zarafa backend to work with new longids.

Released under the Affero GNU General Public License (AGPL) version 3.
parent fea4c43b
......@@ -72,6 +72,7 @@ class ImportChangesICS implements IImportChanges {
private $conflictsState;
private $cutoffdate;
private $contentClass;
private $prefix;
/**
* Constructor
......@@ -91,9 +92,14 @@ class ImportChangesICS implements IImportChanges {
$this->conflictsLoaded = false;
$this->cutoffdate = false;
$this->contentClass = false;
$this->prefix = '';
if ($folderid) {
$entryid = mapi_msgstore_entryidfromsourcekey($store, $folderid);
$folderidForBackendId = ZPush::GetDeviceManager()->GetFolderIdForBackendId($this->folderidHex);
if ($folderidForBackendId != $this->folderidHex) {
$this->prefix = $folderidForBackendId . ':';
}
}
else {
$storeprops = mapi_getprops($store, array(PR_IPM_SUBTREE_ENTRYID));
......@@ -118,6 +124,9 @@ class ImportChangesICS implements IImportChanges {
$this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportContentsChanges, 0 , 0);
else
$this->importer = mapi_openproperty($folder, PR_COLLECTOR, IID_IExchangeImportHierarchyChanges, 0 , 0);
// TODO remove this log output in 2.3.X
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS: prefix:'%s'", $this->prefix));
}
/**
......@@ -383,6 +392,7 @@ class ImportChangesICS implements IImportChanges {
else {
$flags = SYNC_NEW_MESSAGE;
$folderid = ZPush::GetDeviceManager()->GetFolderIdForBackendId($this->folderidHex);
// Only append backend id if the mapping backendid<->folderid is available.
if ($folderid != $this->folderidHex && is_int($folderid) ) {
$fsk = $this->folderidHex;
}
......@@ -397,7 +407,7 @@ class ImportChangesICS implements IImportChanges {
$sourcekeyprops = mapi_getprops($mapimessage, array (PR_SOURCE_KEY));
return ZPush::GetDeviceManager()->GetFolderIdForBackendId($fsk) .":". bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
return $this->prefix . bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
}
else
throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error updating object: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
......@@ -572,7 +582,7 @@ class ImportChangesICS implements IImportChanges {
$sourcekeyprops = mapi_getprops($newmessage, array (PR_SOURCE_KEY));
if (isset($sourcekeyprops[PR_SOURCE_KEY]) && $sourcekeyprops[PR_SOURCE_KEY])
return ZPush::GetDeviceManager()->GetFolderIdForBackendId($newfolder) .":". bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
return $this->prefix . bin2hex($sourcekeyprops[PR_SOURCE_KEY]);
return false;
}
......
......@@ -613,15 +613,17 @@ class BackendZarafa implements IBackend, ISearchProvider {
* @throws StatusException
*/
public function Fetch($folderid, $id, $contentparameters) {
// id might be in the new longid format, so we have to split it here
list($fsk, $sk) = MAPIUtils::SplitMessageId($id);
// get the entry id of the message
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($id));
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($sk));
if(!$entryid)
throw new StatusException(sprintf("BackendZarafa->Fetch('%s','%s'): Error getting entryid: 0x%X", $folderid, $id, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
throw new StatusException(sprintf("BackendZarafa->Fetch('%s','%s'): Error getting entryid: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
// open the message
$message = mapi_msgstore_openentry($this->store, $entryid);
if(!$message)
throw new StatusException(sprintf("BackendZarafa->Fetch('%s','%s'): Error, unable to open message: 0x%X", $folderid, $id, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
throw new StatusException(sprintf("BackendZarafa->Fetch('%s','%s'): Error, unable to open message: 0x%X", $folderid, $sk, mapi_last_hresult()), SYNC_STATUS_OBJECTNOTFOUND);
// convert the mapi message into a SyncObject and return it
$mapiprovider = new MAPIProvider($this->session, $this->store);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment