From 6f9c67d8afeb80016b67d7dd95c3afc1f858725b Mon Sep 17 00:00:00 2001 From: yemkareems Date: Wed, 19 Jun 2024 12:29:44 +0530 Subject: [PATCH] fix: removed unused variable and check if tag ids are empty before starting the inserts Signed-off-by: yemkareems --- lib/private/SystemTag/SystemTagObjectMapper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php index cb24ad29a89..7a2e701515d 100644 --- a/lib/private/SystemTag/SystemTagObjectMapper.php +++ b/lib/private/SystemTag/SystemTagObjectMapper.php @@ -144,11 +144,16 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { $result = $query->executeQuery(); $rows = $result->fetchAll(); $existingTags = []; - foreach ($rows as $k => $row) { + foreach ($rows as $row) { $existingTags[] = $row['systemtagid']; } //filter only tags that do not exist in db $tagIds = array_diff($tagIds, $existingTags); + if (empty($tagIds)) { + // no tags to insert so return here + $this->connection->commit(); + return; + } $query = $this->connection->getQueryBuilder(); $query->insert(self::RELATION_TABLE)