get only vcard which match both the address book id and the vcard uri

This commit is contained in:
Bjoern Schiessle 2016-06-28 16:11:06 +02:00
parent b6397ef73a
commit 5f6944954b
2 changed files with 6 additions and 1 deletions

View File

@ -848,7 +848,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query = $this->db->getQueryBuilder();
$query->select('*')->from($this->dbCardsTable)
->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
$queryResult = $query->execute();
$contact = $queryResult->fetch();
$queryResult->closeCursor();

View File

@ -606,6 +606,11 @@ class CardDavBackendTest extends TestCase {
$this->assertSame(5489543, (int)$result['lastmodified']);
$this->assertSame('etag0', $result['etag']);
$this->assertSame(120, (int)$result['size']);
// this shouldn't return any result because 'uri1' is in address book 1
// see https://github.com/nextcloud/server/issues/229
$result = $this->backend->getContact(0, 'uri1');
$this->assertEmpty($result);
}
public function testGetContactFail() {