diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-15 14:13:04 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-15 14:29:24 +0100 |
commit | df7280a3c7c84671aa0596146503e7a13213b862 (patch) | |
tree | b0c63902012c01641a6ad280cb39b4838223d386 /apps/dav/lib/carddav | |
parent | 46b39c3465e2db9ba26b23d8d0dfca6cc670aaea (diff) | |
download | nextcloud-server-df7280a3c7c84671aa0596146503e7a13213b862.tar.gz nextcloud-server-df7280a3c7c84671aa0596146503e7a13213b862.zip |
Queries on the cards table by uri require the addressbook as well - fixes #22284
Diffstat (limited to 'apps/dav/lib/carddav')
-rw-r--r-- | apps/dav/lib/carddav/addressbookimpl.php | 2 | ||||
-rw-r--r-- | apps/dav/lib/carddav/carddavbackend.php | 17 |
2 files changed, 11 insertions, 8 deletions
diff --git a/apps/dav/lib/carddav/addressbookimpl.php b/apps/dav/lib/carddav/addressbookimpl.php index 1d7b55c1a5d..795a30064b7 100644 --- a/apps/dav/lib/carddav/addressbookimpl.php +++ b/apps/dav/lib/carddav/addressbookimpl.php @@ -178,7 +178,7 @@ class AddressBookImpl implements IAddressBook { protected function createUid() { do { $uid = $this->getUid(); - $contact = $this->backend->getContact($uid . '.vcf'); + $contact = $this->backend->getContact($this->getKey(), $uid . '.vcf'); } while (!empty($contact)); return $uid; diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php index aa2490ab11a..78706ae6bff 100644 --- a/apps/dav/lib/carddav/carddavbackend.php +++ b/apps/dav/lib/carddav/carddavbackend.php @@ -548,7 +548,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { */ function deleteCard($addressBookId, $cardUri) { try { - $cardId = $this->getCardId($cardUri); + $cardId = $this->getCardId($addressBookId, $cardUri); } catch (\InvalidArgumentException $e) { $cardId = null; } @@ -807,15 +807,16 @@ class CardDavBackend implements BackendInterface, SyncSupport { /** * return contact with the given URI * + * @param int $addressBookId * @param string $uri * @returns array */ - public function getContact($uri) { + public function getContact($addressBookId, $uri) { $result = []; $query = $this->db->getQueryBuilder(); $query->select('*')->from($this->dbCardsTable) - ->where($query->expr()->eq('uri', $query->createParameter('uri'))) - ->setParameter('uri', $uri); + ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) + ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); $queryResult = $query->execute(); $contact = $queryResult->fetch(); $queryResult->closeCursor(); @@ -851,7 +852,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { * @param string $vCardSerialized */ protected function updateProperties($addressBookId, $cardUri, $vCardSerialized) { - $cardId = $this->getCardId($cardUri); + $cardId = $this->getCardId($addressBookId, $cardUri); $vCard = $this->readCard($vCardSerialized); $this->purgeProperties($addressBookId, $cardId); @@ -913,13 +914,15 @@ class CardDavBackend implements BackendInterface, SyncSupport { /** * get ID from a given contact * + * @param int $addressBookId * @param string $uri * @return int */ - protected function getCardId($uri) { + protected function getCardId($addressBookId, $uri) { $query = $this->db->getQueryBuilder(); $query->select('id')->from($this->dbCardsTable) - ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))); + ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) + ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); $result = $query->execute(); $cardIds = $result->fetch(); |