Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/systemtags/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected function getSystemTagParameter($parameter) {
if ($tagData === null) {
[$name, $status] = explode('|||', substr($parameter, 3, -3));
$tagData = [
'id' => '0',// No way to recover the ID
'id' => '0', // No way to recover the ID
'name' => $name,
'assignable' => $status === 'assignable',
'visible' => $status !== 'invisible',
Expand Down
13 changes: 13 additions & 0 deletions lib/private/SystemTag/SystemTagObjectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj
$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)
Expand Down Expand Up @@ -324,6 +325,8 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj

$this->updateEtagForTags([$tagId]);
$this->connection->commit();

// Dispatch assign events for new object ids
foreach ($addedObjectIds as $objectId) {
$this->dispatcher->dispatch(MapperEvent::EVENT_ASSIGN, new MapperEvent(
MapperEvent::EVENT_ASSIGN,
Expand All @@ -332,6 +335,16 @@ public function setObjectIdsForTag(string $tagId, string $objectType, array $obj
[(int)$tagId]
));
}

// Dispatch unassign events for removed object ids
foreach ($removedObjectIds as $objectId) {
$this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent(
MapperEvent::EVENT_UNASSIGN,
$objectType,
(string)$objectId,
[(int)$tagId]
));
}
}

/**
Expand Down
Loading