Merge pull request #23437 from owncloud/save-query-when-the-list-is-empty

Save the query when we get tags for no objects
This commit is contained in:
Thomas Müller 2016-03-22 17:12:24 +01:00
commit 6aa28037c7
2 changed files with 12 additions and 1 deletions

View File

@ -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();

View File

@ -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()],