You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/dav/lib/CardDAV/CardDavBackend.php
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -921,18 +921,20 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel,
921
921
922
922
// Fetching all changes
923
923
$stmt = $qb->executeQuery();
924
+
$rowCount = $stmt->rowCount();
924
925
925
926
$changes = [];
927
+
$highestSyncToken = 0;
926
928
927
929
// This loop ensures that any duplicates are overwritten, only the
928
930
// last change on a node is relevant.
929
931
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
930
932
$changes[$row['uri']] = $row['operation'];
931
-
// get the last synctoken, needed in case a limit was set
932
-
$result['syncToken'] = $row['synctoken'];
933
+
$highestSyncToken = $row['synctoken'];
933
934
}
935
+
934
936
$stmt->closeCursor();
935
-
937
+
936
938
// No changes found, use current token
937
939
if (empty($changes)) {
938
940
$result['syncToken'] = $currentToken;
@@ -951,6 +953,20 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel,
951
953
break;
952
954
}
953
955
}
956
+
957
+
/*
958
+
* The synctoken in oc_addressbooks is always the highest synctoken in oc_addressbookchanges for a given addressbook plus one (see addChange).
959
+
*
960
+
* For truncated results, it is expected that we return the highest token from the response, so the client can continue from the latest change.
961
+
*
962
+
* For non-truncated results, it is expected to return the currentToken. If we return the highest token, as with truncated results, the client will always think it is one change behind.
963
+
*
964
+
* Therefore, we differentiate between truncated and non-truncated results when returning the synctoken.
965
+
*/
966
+
if ($rowCount === $limit && $highestSyncToken < $currentToken) {
0 commit comments