Skip to content

Commit 836498f

Browse files
authored
Fix import and display of multiple tags from the same category (#614)
When an object had more than one tag from a MULTIPLE-cardinality category, `TagLookup` silently discarded all but the last tag due to swapped `if`/`else` branches. `TaggingDetails` rendered the category row once per tag because the JOIN was not grouped. Swap the branches and add `GROUP BY tc.uuid` to fix both.
1 parent 5a2f1d5 commit 836498f

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

library/Vspheredb/Db/TagLookup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function getTags(string $objectUuid): stdClass
5454
$result[$categoryName] = $tag->get('name');
5555
} else {
5656
if (isset($result[$categoryName])) {
57-
$result[$categoryName] = [$tag->get('name')];
58-
} else {
5957
$result[$categoryName][] = $tag->get('name');
58+
} else {
59+
$result[$categoryName] = [$tag->get('name')];
6060
}
6161
}
6262
}

library/Vspheredb/Web/Widget/TaggingDetails.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function __construct(BaseDbObject $object)
5252
->join(['tt' => TaggingTag::TABLE], 'tt.category_uuid = tc.uuid', [])
5353
->join(['tot' => TaggingObjectTag::TABLE], 'tot.tag_uuid = tt.uuid', [])
5454
->where('tot.object_uuid = ?', $object->get('uuid'))
55+
->group('tc.uuid')
5556
->order('tc.name');
5657
$this->categories = TaggingCategory::loadAll($connection, $where);
5758
// $this->setDemoTags();

0 commit comments

Comments
 (0)