mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-05 21:49:28 +01:00
Fix chunked item issue (bug#2576)
This commit is contained in:
parent
4987cc1b4d
commit
e99558d39f
@ -20,14 +20,15 @@ class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
|
||||
|
||||
var $_luid;
|
||||
var $_guid;
|
||||
var $_contentSize;
|
||||
var $_contentSize = 0;
|
||||
var $_contentType;
|
||||
var $_contentFormat;
|
||||
var $_status = RESPONSE_OK;
|
||||
var $_curItem;
|
||||
var $_items = array();
|
||||
var $_failed = array();
|
||||
var $_moreData = false;
|
||||
var $_command = false;
|
||||
var $_command = false;
|
||||
|
||||
function &factory($command, $params = null) {
|
||||
include_once 'Horde/SyncML/Command/Sync/SyncElementItem.php';
|
||||
@ -89,26 +90,36 @@ class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
|
||||
break;
|
||||
case 2;
|
||||
if($element == 'Item') {
|
||||
if($this->_luid) {
|
||||
if ($this->_luid) {
|
||||
$this->_curItem->setLocURI($this->_luid);
|
||||
$this->_curItem->setContentType($this->_contentType);
|
||||
$this->_curItem->setContentFormat($this->_contentFormat);
|
||||
$this->_curItem->setCommand($this->_command);
|
||||
|
||||
if($this->_contentSize)
|
||||
if ($this->_contentSize)
|
||||
$this->_curItem->setContentSize($this->_contentSize);
|
||||
if($this->_moreData) {
|
||||
if ($this->_moreData) {
|
||||
$state->curSyncItem = &$this->_curItem;
|
||||
Horde::logMessage('SyncML: moreData item saved for LocURI ' . $this->_curItem->_luid, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
} else {
|
||||
if (strtolower($this->_curItem->getContentFormat()) == 'b64') {
|
||||
$content = $this->_curItem->getContent();
|
||||
$content = ($content ? base64_decode($content) : '');
|
||||
$this->_curItem->setContent($content);
|
||||
#Horde::logMessage('SyncML: BASE64 encoded item for LocURI '
|
||||
# . $this->_curItem->_luid . ":\n $content", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$content = $this->_curItem->getContent();
|
||||
$contentSize = strlen($content);
|
||||
if ((($size = $this->_curItem->getContentSize()) !== false) &&
|
||||
abs($contentSize - $size) > 3) {
|
||||
Horde::logMessage('SyncML: content size mismatch for LocURI ' . $this->_luid .
|
||||
": $contentSize ($size) : " . $content,
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$this->_failed[$this->_luid] = $this->_curItem;
|
||||
} else {
|
||||
if (strtolower($this->_curItem->getContentFormat()) == 'b64') {
|
||||
$content = ($content ? base64_decode($content) : '');
|
||||
$this->_curItem->setContent($content);
|
||||
#Horde::logMessage('SyncML: BASE64 encoded item for LocURI '
|
||||
# . $this->_curItem->_luid . ":\n $content", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
}
|
||||
#Horde::logMessage('SyncML: Data for ' . $this->_luid . ': ' . $this->_curItem->getContent(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$this->_items[$this->_luid] = $this->_curItem;
|
||||
}
|
||||
$this->_items[$this->_luid] = $this->_curItem;
|
||||
}
|
||||
}
|
||||
unset($this->_contentSize);
|
||||
@ -118,13 +129,16 @@ class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
|
||||
case 3:
|
||||
switch ($element) {
|
||||
case 'Data':
|
||||
$this->_curItem->_content .= $this->_chars;
|
||||
$content = $this->_chars;
|
||||
if ($this->_contentFormat == 'b64') $content = trim($content);
|
||||
#Horde::logMessage('SyncML: Data for ' . $this->_luid . ': ' . $content, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$this->_curItem->_content .= $content;
|
||||
break;
|
||||
case 'MoreData':
|
||||
$this->_moreData = true;
|
||||
break;
|
||||
case 'Type':
|
||||
if(empty($this->_contentType)) {
|
||||
if (empty($this->_contentType)) {
|
||||
$this->_contentType = trim($this->_chars);
|
||||
}
|
||||
break;
|
||||
@ -132,7 +146,7 @@ class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
|
||||
$this->_contentFormat = strtolower(trim($this->_chars));
|
||||
break;
|
||||
case 'Size':
|
||||
$this->_contentSize = $this->_chars;
|
||||
$this->_contentSize = trim($this->_chars);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -163,6 +177,10 @@ class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
|
||||
function getSyncElementItems() {
|
||||
return (array)$this->_items;
|
||||
}
|
||||
|
||||
function getSyncElementFailures() {
|
||||
return (array)$this->_failed;
|
||||
}
|
||||
|
||||
function getLocURI()
|
||||
{
|
||||
|
@ -90,7 +90,11 @@ class Horde_SyncML_Sync {
|
||||
}
|
||||
|
||||
function nextSyncCommand($currentCmdID, &$syncCommand, &$output) {
|
||||
$result = $this->runSyncCommand($syncCommand);
|
||||
$this->runSyncCommand($syncCommand);
|
||||
if ($syncCommand->hasMoreData()) {
|
||||
Horde::logMessage('SyncML: moreData: TRUE', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$syncCommand->setStatus(RESPONSE_CHUNKED_ITEM_ACCEPTED_AND_BUFFERED);
|
||||
}
|
||||
return $syncCommand->output($currentCmdID, $output);
|
||||
}
|
||||
|
||||
@ -157,11 +161,6 @@ class Horde_SyncML_Sync {
|
||||
$history = $GLOBALS['egw']->contenthistory;
|
||||
$state = &$_SESSION['SyncML.state'];
|
||||
|
||||
if ($command->hasMoreData()) {
|
||||
Horde::logMessage('SyncML: moreData: TRUE', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$command->setStatus(RESPONSE_CHUNKED_ITEM_ACCEPTED_AND_BUFFERED);
|
||||
return true;
|
||||
}
|
||||
|
||||
$type = $this->_targetLocURI;
|
||||
|
||||
@ -210,16 +209,6 @@ class Horde_SyncML_Sync {
|
||||
|
||||
$guid = false;
|
||||
|
||||
$contentSize = strlen($syncItem->_content);
|
||||
if ((($size = $syncItem->getContentSize()) !== false) &&
|
||||
abs($contentSize - $size) > 3) {
|
||||
Horde::logMessage('SyncML: content size mismatch for LocURI '
|
||||
. $syncItem->getLocURI() . ": $contentSize ($size)",
|
||||
__FILE__, __LINE__, PEAR_LOG_ERROR);
|
||||
$command->setStatus(RESPONSE_SIZE_MISMATCH);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_a($command, 'Horde_SyncML_Command_Sync_Add')) {
|
||||
if ($sync_conflicts > CONFLICT_RESOLVED_WITH_DUPLICATE) {
|
||||
// We enforce the client not to change anything
|
||||
@ -454,6 +443,5 @@ class Horde_SyncML_Sync {
|
||||
}
|
||||
}
|
||||
}
|
||||
return $guid;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Horde_SyncML_Sync_RefreshFromServerSync extends Horde_SyncML_Sync_TwoWaySy
|
||||
if (!is_a($cmd, 'Horde_SyncML_Command_Sync_ContentSyncElement')) {
|
||||
// Conflict with other datastore
|
||||
Horde :: logMessage("SyncML: handleSync($currentCmdID, $hordeType, $syncType) moreData conflict found",
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
|
||||
return $currentCmdID;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
if (!is_a($cmd, 'Horde_SyncML_Command_Sync_ContentSyncElement')) {
|
||||
// Conflict with other datastore
|
||||
Horde :: logMessage("SyncML: handleSync($currentCmdID, $hordeType, $syncType) moreData conflict found",
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
|
||||
return $currentCmdID;
|
||||
}
|
||||
@ -202,12 +202,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
$history = $GLOBALS['egw']->contenthistory;
|
||||
$state = &$_SESSION['SyncML.state'];
|
||||
|
||||
if ($command->hasMoreData()) {
|
||||
Horde::logMessage('SyncML: moreData: TRUE', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$command->setStatus(RESPONSE_CHUNKED_ITEM_ACCEPTED_AND_BUFFERED);
|
||||
return true;
|
||||
}
|
||||
|
||||
$type = $this->_targetLocURI;
|
||||
|
||||
$syncml_prefs = $GLOBALS['egw_info']['user']['preferences']['syncml'];
|
||||
@ -223,15 +217,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
|
||||
foreach($syncElementItems as $syncItem) {
|
||||
|
||||
$contentSize = strlen($syncItem->_content);
|
||||
if ((($size = $syncItem->getContentSize()) !== false) &&
|
||||
abs($contentSize - $size) > 3) {
|
||||
Horde::logMessage('SyncML: content size mismatch for LocURI ' . $syncItem->_luid .
|
||||
": $contentSize ($size)", __FILE__, __LINE__, PEAR_LOG_ERROR);
|
||||
$command->setStatus(RESPONSE_SIZE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$contentType = $syncItem->getContentType()) {
|
||||
$contentType = $state->getPreferedContentType($type);
|
||||
}
|
||||
@ -248,7 +233,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
$guid = $registry->call($hordeType . '/search',
|
||||
array($state->convertClient2Server($syncItem->getContent(), $contentType), $contentType, $oguid, $type));
|
||||
|
||||
if ($guid) {
|
||||
if (!is_a($guid, 'PEAR_Error') && $guid) {
|
||||
// Check if the found entry came from the client
|
||||
$guid_ts = $state->getSyncTSforAction($guid, 'add');
|
||||
$sync_ts = $state->getChangeTS($type, $guid);
|
||||
@ -292,7 +277,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$guid = $registry->call($hordeType . '/import',
|
||||
array($state->convertClient2Server($syncItem->getContent(), $contentType), $contentType));
|
||||
if (!is_a($guid, 'PEAR_Error') && $guid != false) {
|
||||
if (!is_a($guid, 'PEAR_Error') && $guid) {
|
||||
$state->setUID($type, $syncItem->getLocURI(), $guid);
|
||||
$state->log("Client-AddReplace");
|
||||
Horde::logMessage('SyncML: replaced/added client entry as ' . $guid,
|
||||
@ -303,8 +288,6 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
$state->log("Client-AddFailure");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
|
@ -65,7 +65,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
if (!is_a($cmd, 'Horde_SyncML_Command_Sync_ContentSyncElement')) {
|
||||
// Conflict with other datastore
|
||||
Horde :: logMessage("SyncML: handleSync($currentCmdID, $hordeType, $syncType) moreData conflict found",
|
||||
__FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
|
||||
return $currentCmdID;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user