mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-11 00:18:25 +01:00
Fix conflict handling issues
This commit is contained in:
parent
b3a1f2de10
commit
81d8ea7bbb
@ -417,16 +417,39 @@ class Horde_SyncML_State {
|
||||
$this->_addedItems[$_type] = $_addedItems;
|
||||
}
|
||||
|
||||
function pushAddedItem($_type, $_addedItems)
|
||||
function mergeAddedItems($_type, $_addedItems)
|
||||
{
|
||||
if (is_array($this->_addedItems[$_type])) {
|
||||
$this->_addedItems[$_type] = array_merge($this->_addedItems[$_type], $_addedItems);
|
||||
} else {
|
||||
$this->_addedItems[$_type] = $_addedItems;
|
||||
}
|
||||
}
|
||||
|
||||
function pushAddedItem($_type, $_addedItem)
|
||||
{
|
||||
$this->_addedItems[$_type][] = $_addedItem;
|
||||
}
|
||||
|
||||
function setChangedItems($_type, $_changedItems)
|
||||
{
|
||||
$this->_changedItems[$_type] = $_changedItems;
|
||||
}
|
||||
|
||||
function mergeChangedItems($_type, $_changedItems)
|
||||
{
|
||||
if (is_array($this->_changedItems[$_type])) {
|
||||
$this->_changedItems[$_type] = array_merge($this->_changedItems[$_type], $_changedItems);
|
||||
} else {
|
||||
$this->_changedItems[$_type] = $_changedItems;
|
||||
}
|
||||
}
|
||||
|
||||
function pushChangedItem($_type, $_changedItem)
|
||||
{
|
||||
$this->_changedItems[$_type][] = $_changedItem;
|
||||
}
|
||||
|
||||
function setClientDeviceInfo($clientDeviceInfo)
|
||||
{
|
||||
$this->_clientDeviceInfo = $clientDeviceInfo;
|
||||
|
@ -235,7 +235,7 @@ class Horde_SyncML_Sync {
|
||||
Horde::logMessage('SyncML: Server RO! REMOVE '
|
||||
. $syncItem->getLocURI() . ' from client',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->addConflictItem($type, '!D' . $syncItem->getLocURI());
|
||||
$state->addConflictItem($type, $syncItem->getLocURI());
|
||||
} else {
|
||||
Horde::logMessage('SyncML: Server RO! '
|
||||
. 'REJECT all client changes',
|
||||
@ -275,7 +275,7 @@ class Horde_SyncML_Sync {
|
||||
Horde::logMessage('SyncML: Server RO! ADD '
|
||||
. $guid . ' to client again',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
// $state->addConflictItem($type, $guid);
|
||||
$state->pushAddedItem($type, $guid);
|
||||
} else {
|
||||
Horde::logMessage('SyncML: '.
|
||||
'Server RO! REJECT all client changes',
|
||||
@ -298,7 +298,7 @@ class Horde_SyncML_Sync {
|
||||
Horde::logMessage('SyncML: Server Merge Only: ADD '
|
||||
. $guid . ' to client again',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
// $state->addConflictItem($type, $guid);
|
||||
$state->pushAddedItem($type, $guid);
|
||||
$state->log('Client-DeleteIgnored');
|
||||
continue;
|
||||
}
|
||||
@ -368,7 +368,7 @@ class Horde_SyncML_Sync {
|
||||
Horde::logMessage('SyncML: Server RO! UNDO client change for locuri ' .
|
||||
$syncItem->getLocURI() . ' guid ' . $guid ,
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->addConflictItem($type, $guid);
|
||||
$state->pushChangedItem($type, $guid);
|
||||
$ok = true;
|
||||
$replace = false;
|
||||
}
|
||||
@ -421,7 +421,7 @@ class Horde_SyncML_Sync {
|
||||
// delete this item from client
|
||||
Horde::logMessage('SyncML: Server RO! REMOVE ' . $syncItem->getLocURI() . ' from client',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->addConflictItem($type, '!D' . $syncItem->getLocURI());
|
||||
$state->addConflictItem($type, $syncItem->getLocURI());
|
||||
} else {
|
||||
Horde::logMessage('SyncML: Server RO! REJECT all client changes',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
|
@ -226,7 +226,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
// delete this item from client
|
||||
Horde::logMessage('SyncML: Server RO! REMOVE ' . $syncItem->getLocURI()
|
||||
. ' from client', __FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$state->addConflictItem($type, '!D' . $syncItem->getLocURI());
|
||||
$state->addConflictItem($type, $syncItem->getLocURI());
|
||||
} else {
|
||||
Horde::logMessage('SyncML: Server RO! REJECT all client changes',
|
||||
__FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
@ -274,7 +274,7 @@ class Horde_SyncML_Sync_SlowSync extends Horde_SyncML_Sync_TwoWaySync {
|
||||
'timestamp' => $future,
|
||||
'type' => $syncType,
|
||||
'filter' => $this->_filterExpression)));
|
||||
$state->setAddedItems($syncType, $registry->call($hordeType. '/list', array('filter' => $this->_filterExpression)));
|
||||
$state->mergeAddedItems($syncType, $registry->call($hordeType. '/list', array('filter' => $this->_filterExpression)));
|
||||
$this->_syncDataLoaded = TRUE;
|
||||
|
||||
return count($state->getAddedItems($syncType)) - $delta_add;
|
||||
|
@ -82,20 +82,10 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
$adds = & $state->getAddedItems($syncType);
|
||||
$conflicts = & $state->getConflictItems($syncType);
|
||||
|
||||
// manage the conflict items
|
||||
foreach ( $conflicts as $refresh) {
|
||||
if (preg_match('/^!D(.*)/', $refresh, $matches)) {
|
||||
// delete locuri
|
||||
$remoteDeletes[] = $matches[1];
|
||||
} else {
|
||||
$adds[] = $refresh;
|
||||
}
|
||||
}
|
||||
|
||||
Horde :: logMessage('SyncML: ' . count($changes) . ' changed items found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde :: logMessage('SyncML: ' . count($deletes) . ' deleted items found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde :: logMessage('SyncML: ' . count($remoteDeletes) . ' items to delete on client found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde :: logMessage('SyncML: ' . count($adds) . ' added items (' . count($refresh) . ' refreshs) found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde :: logMessage('SyncML: ' . count($conflicts) . ' items to delete on client found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
Horde :: logMessage('SyncML: ' . count($adds) . ' added items found for ' . $syncType, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
|
||||
// handle changes
|
||||
if (is_array($changes)) {
|
||||
@ -254,8 +244,8 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
}
|
||||
|
||||
// handle remote deletes due to conflicts
|
||||
if (count($remoteDeletes) > 0) {
|
||||
while ($locid = array_shift($remoteDeletes)) {
|
||||
if (count($conflicts) > 0) {
|
||||
while ($locid = array_shift($conflicts)) {
|
||||
$currentSize = $output->getOutputSize();
|
||||
// return if we have to much data
|
||||
if (($maxEntries && ($state->getNumberOfElements() >= $maxEntries)
|
||||
@ -264,7 +254,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
|| ($maxMsgSize
|
||||
&& (($currentSize +MIN_MSG_LEFT * 2) > $maxMsgSize))) {
|
||||
// put the item back in the queue
|
||||
$remoteDeletes[] = $locid;
|
||||
$conflicts[] = $locid;
|
||||
$state->maxNumberOfElements();
|
||||
$state->setSyncStatus(SERVER_SYNC_DATA_PENDING);
|
||||
return $currentCmdID;
|
||||
@ -420,7 +410,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
'type' => $syncType,
|
||||
'filter' => $this->_filterExpression
|
||||
)));
|
||||
$state->setChangedItems($syncType, $registry->call($hordeType . '/listBy', array (
|
||||
$state->mergeChangedItems($syncType, $registry->call($hordeType . '/listBy', array (
|
||||
'action' => 'modify',
|
||||
'timestamp' => $refts,
|
||||
'type' => $syncType,
|
||||
@ -442,7 +432,7 @@ class Horde_SyncML_Sync_TwoWaySync extends Horde_SyncML_Sync {
|
||||
'type' => $syncType,
|
||||
'filter' => $this->_filterExpression
|
||||
)));
|
||||
$state->setAddedItems($syncType, $registry->call($hordeType . '/listBy', array (
|
||||
$state->mergeAddedItems($syncType, $registry->call($hordeType . '/listBy', array (
|
||||
'action' => 'add',
|
||||
'timestamp' => $refts,
|
||||
'type' => $syncType,
|
||||
|
Loading…
Reference in New Issue
Block a user