]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix sync errors for duplicate cards with the same UID for different backends 32057/head
authorAnna Larch <anna@nextcloud.com>
Thu, 21 Apr 2022 19:27:11 +0000 (21:27 +0200)
committerAnna (Rebase PR Action) <miaulalala@users.noreply.github.com>
Thu, 5 Jan 2023 12:19:51 +0000 (12:19 +0000)
Signed-off-by: Anna Larch <anna@nextcloud.com>
apps/dav/lib/CardDAV/Converter.php
apps/dav/lib/CardDAV/SyncService.php

index 340e3127f0a765054f7bce31b4ab3aa349f9ac84..8452810c29e200c4fb79b2afdd8232c3c02af913 100644 (file)
@@ -47,12 +47,14 @@ class Converter {
                $userProperties = $this->accountManager->getAccount($user)->getProperties();
 
                $uid = $user->getUID();
+               $backendClassName = $user->getBackendClassName();
                $cloudId = $user->getCloudId();
                $image = $this->getAvatarImage($user);
 
                $vCard = new VCard();
                $vCard->VERSION = '3.0';
-               $vCard->UID = $uid;
+               $vCard->UID = md5("$backendClassName:$uid");
+               $vCard->add(new Text($vCard, 'X-NEXTCLOUD-UID', $uid));
 
                $publish = false;
 
index da798c5768e5629ea25ee8b0cd0c6c8f957c3402..d73ec9029f9925df04f511b36ac74f3d6bce50bd 100644 (file)
@@ -274,7 +274,7 @@ class SyncService {
                $allCards = $this->backend->getCards($systemAddressBook['id']);
                foreach ($allCards as $card) {
                        $vCard = Reader::read($card['carddata']);
-                       $uid = $vCard->UID->getValue();
+                       $uid = isset($vCard->{'X-NEXTCLOUD-UID'}) ? $vCard->{'X-NEXTCLOUD-UID'}->getValue() : $vCard->UID->getValue();
                        // load backend and see if user exists
                        if (!$this->userManager->userExists($uid)) {
                                $this->deleteUser($card['uri']);