From 38e5446e115b2c9b1d12bc896ef180d75beb5fb7 Mon Sep 17 00:00:00 2001 From: Olaf Braun Date: Fri, 10 Nov 2023 09:24:07 +0100 Subject: [PATCH] Delete also old langauge items in save function --- .../data/TI18nDatabaseObjectAction.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/data/TI18nDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/TI18nDatabaseObjectAction.class.php index 5e8ddbddcd..15e295f9e2 100644 --- a/wcfsetup/install/files/lib/data/TI18nDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/TI18nDatabaseObjectAction.class.php @@ -32,6 +32,14 @@ trait TI18nDatabaseObjectAction } } } + $this->deleteI18Items($langaugeItems); + } + + /** + * Deletes language items and clears the language cache. + */ + private function deleteI18Items(array $langaugeItems): void + { if ($langaugeItems !== []) { //find language category id $sql = "SELECT languageCategoryID @@ -87,12 +95,11 @@ trait TI18nDatabaseObjectAction */ protected function saveI18nValue(DatabaseObject $object): void { - $updateData = []; + $updateData = $deleteData = []; foreach ($this->getI18nSaveTypes() as $name => $regex) { + $languageName = \str_replace('\d+', $object->getObjectID(), $regex); if (isset($this->parameters[$name . '_i18n'])) { - $languageName = \str_replace('\d+', $object->getObjectID(), $regex); - I18nHandler::getInstance()->save( $this->parameters[$name . '_i18n'], $languageName, @@ -101,8 +108,12 @@ trait TI18nDatabaseObjectAction ); $updateData[$name] = $languageName; + } else { + $deleteData[] = $languageName; } } + $this->deleteI18Items($deleteData); + if (!empty($updateData)) { $editor = new $this->className($object); $editor->update($updateData); -- 2.20.1