aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2025-03-25 13:22:44 +0100
committerGitHub <noreply@github.com>2025-03-25 13:22:44 +0100
commit2f7e72fc5079b909e005e0917f96174148589819 (patch)
treee06bf2b62e7d8c6f5e651217c4a14c489209a35d
parent2d813f15ab45434b86825f343845244aa56c1bb2 (diff)
parenta842d917cf7f1264f7c38259c96da639fa7c4910 (diff)
downloadnextcloud-server-2f7e72fc5079b909e005e0917f96174148589819.tar.gz
nextcloud-server-2f7e72fc5079b909e005e0917f96174148589819.zip
Merge pull request #51649 from rolandinus/fix/dispatch-events-on-bulk-tagging
fix(systemtags): Dispatch events when bulk assigning system tags
-rw-r--r--lib/private/SystemTag/SystemTagObjectMapper.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php
index 09a7ce1a6ed..3881336bf37 100644
--- a/lib/private/SystemTag/SystemTagObjectMapper.php
+++ b/lib/private/SystemTag/SystemTagObjectMapper.php
@@ -284,6 +284,9 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
* {@inheritdoc}
*/
public function setObjectIdsForTag(string $tagId, string $objectType, array $objectIds): void {
+ $currentObjectIds = $this->getObjectIdsForTags($tagId, $objectType);
+ $removedObjectIds = array_diff($currentObjectIds, $objectIds);
+ $addedObjectIds = array_diff($objectIds, $currentObjectIds);
$this->connection->beginTransaction();
$query = $this->connection->getQueryBuilder();
$query->delete(self::RELATION_TABLE)
@@ -292,6 +295,15 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->executeStatement();
$this->connection->commit();
+ foreach ($removedObjectIds as $objectId) {
+ $this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent(
+ MapperEvent::EVENT_UNASSIGN,
+ $objectType,
+ (string)$objectId,
+ [(int)$tagId]
+ ));
+ }
+
if (empty($objectIds)) {
return;
}
@@ -312,6 +324,14 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
$this->updateEtagForTags([$tagId]);
$this->connection->commit();
+ foreach ($addedObjectIds as $objectId) {
+ $this->dispatcher->dispatch(MapperEvent::EVENT_ASSIGN, new MapperEvent(
+ MapperEvent::EVENT_ASSIGN,
+ $objectType,
+ (string)$objectId,
+ [(int)$tagId]
+ ));
+ }
}
/**