Merge pull request #16822 from nextcloud/bugfix/fat-75/database-error-on-occ-scan-with-autotaggging

Only trigger the events with tags that where actually assigned
This commit is contained in:
blizzz 2019-08-21 15:04:38 +02:00 committed by GitHub
commit 1d782aa13c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -154,20 +154,26 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
'systemtagid' => $query->createParameter('tagid'),
]);
$tagsAssigned = [];
foreach ($tagIds as $tagId) {
try {
$query->setParameter('tagid', $tagId);
$query->execute();
$tagsAssigned[] = $tagId;
} catch (UniqueConstraintViolationException $e) {
// ignore existing relations
}
}
if (empty($tagsAssigned)) {
return;
}
$this->dispatcher->dispatch(MapperEvent::EVENT_ASSIGN, new MapperEvent(
MapperEvent::EVENT_ASSIGN,
$objectType,
$objId,
$tagIds
$tagsAssigned
));
}