diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-22 17:12:24 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-22 17:12:24 +0100 |
commit | 6aa28037c7d611f91c4f5fa2e4df5b9ab9e51a54 (patch) | |
tree | b94d59b191b5ee1895b1ae010da0d2bfcfe65112 | |
parent | ffe57a55d973e244fc84573323e3da8512e1ac95 (diff) | |
parent | dcca20a48a18cf9349084851ab4bbc05046808b3 (diff) | |
download | nextcloud-server-6aa28037c7d611f91c4f5fa2e4df5b9ab9e51a54.tar.gz nextcloud-server-6aa28037c7d611f91c4f5fa2e4df5b9ab9e51a54.zip |
Merge pull request #23437 from owncloud/save-query-when-the-list-is-empty
Save the query when we get tags for no objects
-rw-r--r-- | lib/private/systemtag/systemtagobjectmapper.php | 2 | ||||
-rw-r--r-- | tests/lib/systemtag/systemtagobjectmappertest.php | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/systemtag/systemtagobjectmapper.php b/lib/private/systemtag/systemtagobjectmapper.php index 586351cf8c1..412842b69e3 100644 --- a/lib/private/systemtag/systemtagobjectmapper.php +++ b/lib/private/systemtag/systemtagobjectmapper.php @@ -64,6 +64,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { public function getTagIdsForObjects($objIds, $objectType) { if (!is_array($objIds)) { $objIds = [$objIds]; + } else if (empty($objIds)) { + return []; } $query = $this->connection->getQueryBuilder(); diff --git a/tests/lib/systemtag/systemtagobjectmappertest.php b/tests/lib/systemtag/systemtagobjectmappertest.php index 861eb240674..69cf7e8f816 100644 --- a/tests/lib/systemtag/systemtagobjectmappertest.php +++ b/tests/lib/systemtag/systemtagobjectmappertest.php @@ -119,7 +119,7 @@ class SystemTagObjectMapperTest extends TestCase { $query->delete(SystemTagManager::TAG_TABLE)->execute(); } - public function testGetTagsForObjects() { + public function testGetTagIdsForObjects() { $tagIdMapping = $this->tagMapper->getTagIdsForObjects( ['1', '2', '3', '4'], 'testtype' @@ -133,6 +133,15 @@ class SystemTagObjectMapperTest extends TestCase { ], $tagIdMapping); } + public function testGetTagIdsForNoObjects() { + $tagIdMapping = $this->tagMapper->getTagIdsForObjects( + [], + 'testtype' + ); + + $this->assertEquals([], $tagIdMapping); + } + public function testGetObjectsForTags() { $objectIds = $this->tagMapper->getObjectIdsForTags( [$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()], |