Merge pull request #3931 from nextcloud/downstream-27295

Don't store empty groupids
This commit is contained in:
Roeland Jago Douma 2017-03-20 08:48:10 +01:00 committed by GitHub
commit 81647a58db
2 changed files with 12 additions and 0 deletions

View File

@ -400,6 +400,9 @@ class SystemTagManager implements ISystemTagManager {
'gid' => $query->createParameter('gid'),
]);
foreach ($groupIds as $groupId) {
if ($groupId === '') {
continue;
}
$query->setParameter('gid', $groupId);
$query->execute();
}

View File

@ -516,6 +516,15 @@ class SystemTagManagerTest extends TestCase {
$this->assertEquals([], $this->tagManager->getTagGroups($tag2));
}
/**
* empty groupIds should be ignored
*/
public function testEmptyTagGroup() {
$tag1 = $this->tagManager->createTag('tag1', true, false);
$this->tagManager->setTagGroups($tag1, ['']);
$this->assertEquals([], $this->tagManager->getTagGroups($tag1));
}
/**
* @param ISystemTag $tag1
* @param ISystemTag $tag2