From: Olaf Braun Date: Fri, 10 Nov 2023 08:24:07 +0000 (+0100) Subject: Delete also old langauge items in save function X-Git-Tag: 6.0.3_dev_1~15^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=38e5446e115b2c9b1d12bc896ef180d75beb5fb7;p=GitHub%2FWoltLab%2FWCF.git Delete also old langauge items in save function --- 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);