From 4d62dac9edb0bb0161579f740306d109b98c95cb Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 13 Nov 2024 15:39:55 +0000
Subject: [PATCH] don't store translations of I18NString if they are equal to
 the original base string, fixes #4863

Closes #4863

Merge request studip/studip!3646
---
 lib/classes/I18NString.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/classes/I18NString.php b/lib/classes/I18NString.php
index f877c58118d..a8187e6af97 100644
--- a/lib/classes/I18NString.php
+++ b/lib/classes/I18NString.php
@@ -269,10 +269,11 @@ class I18NString implements JsonSerializable
                 throw new RuntimeException('store not possible, metadata is missing');
             }
             /* Replace translations */
-            $deleted = $db->execute("DELETE FROM i18n WHERE object_id = ? AND `table` = ? AND field = ?", [$object_id, $table, $field]);
+            $db->execute("DELETE FROM i18n WHERE object_id = ? AND `table` = ? AND field = ?", [$object_id, $table, $field]);
+
             $i18nSQL = $db->prepare("INSERT INTO `i18n` (`object_id`, `table`, `field`, `lang`, `value`) VALUES (?,?,?,?,?)");
             foreach ($this->lang as $lang => $value) {
-                if (mb_strlen($value)) {
+                if (mb_strlen($value) && $value !== $this->base) {
                     $i18nSQL->execute([$object_id, $table, $field, $lang, (string) $value]);
                 }
             }
-- 
GitLab