mirror of
https://github.com/nextcloud/server.git
synced 2026-02-28 12:30:40 -05:00
Merge pull request #51690 from nextcloud/backport/51649/stable31
[stable31] fix(systemtags): Dispatch events when bulk assigning system tags
This commit is contained in:
commit
e8f010571e
1 changed files with 20 additions and 0 deletions
|
|
@ -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]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue