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
@@ -920,18 +920,20 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel,
920
920
921
921
// Fetching all changes
922
922
$stmt = $qb->executeQuery();
923
+
$rowCount = $stmt->rowCount();
923
924
924
925
$changes = [];
926
+
$highestSyncToken = 0;
925
927
926
928
// This loop ensures that any duplicates are overwritten, only the
927
929
// last change on a node is relevant.
928
930
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
929
931
$changes[$row['uri']] = $row['operation'];
930
-
// get the last synctoken, needed in case a limit was set
931
-
$result['syncToken'] = $row['synctoken'];
932
+
$highestSyncToken = $row['synctoken'];
932
933
}
934
+
933
935
$stmt->closeCursor();
934
-
936
+
935
937
// No changes found, use current token
936
938
if (empty($changes)) {
937
939
$result['syncToken'] = $currentToken;
@@ -950,6 +952,20 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel,
950
952
break;
951
953
}
952
954
}
955
+
956
+
/*
957
+
* The synctoken in oc_addressbooks is always the highest synctoken in oc_addressbookchanges for a given addressbook plus one (see addChange).
958
+
*
959
+
* For truncated results, it is expected that we return the highest token from the response, so the client can continue from the latest change.
960
+
*
961
+
* 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.
962
+
*
963
+
* Therefore, we differentiate between truncated and non-truncated results when returning the synctoken.
964
+
*/
965
+
if ($rowCount === $limit && $highestSyncToken < $currentToken) {
0 commit comments