diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php index 7b16262a680e3a776cd1eb852893d31a1c4a5f02..b2597baedc6336252e274491613aba4c12449b7a 100644 --- a/apps/dav/lib/carddav/carddavbackend.php +++ b/apps/dav/lib/carddav/carddavbackend.php @@ -134,7 +134,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { * @param string $principalUri * @param string $url Just the 'basename' of the url. * @param array $properties - * @return void + * @throws BadRequest */ function createAddressBook($principalUri, $url, array $properties) { $values = [ @@ -160,6 +160,12 @@ class CardDavBackend implements BackendInterface, SyncSupport { } + // Fallback to make sure the displayname is set. Some clients may refuse + // to work with addressbooks not having a displayname. + if(is_null($values['displayname'])) { + $values['displayname'] = $url; + } + $query = $this->db->getQueryBuilder(); $query->insert('addressbooks') ->values([ diff --git a/apps/dav/tests/unit/carddav/carddavbackendtest.php b/apps/dav/tests/unit/carddav/carddavbackendtest.php index f7456e9634c3511fb4cf462d23c1b3de8a7329ea..79ef36d8097fa310c9c41582c9e7d419c471a890 100644 --- a/apps/dav/tests/unit/carddav/carddavbackendtest.php +++ b/apps/dav/tests/unit/carddav/carddavbackendtest.php @@ -60,6 +60,7 @@ class CardDavBackendTest extends TestCase { $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER); $this->assertEquals(1, count($books)); + $this->assertEquals('Example', $books[0]['{DAV:}displayname']); // update it's display name $patch = new PropPatch([