From: Matthias Schmidt Date: Sat, 4 Jan 2020 16:08:06 +0000 (+0100) Subject: Fix legacy i18n value handling in i18n form fields X-Git-Tag: 5.2.1~19 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a0991dc9098fb05eb5423a6fd761579df53c85fa;p=GitHub%2FWoltLab%2FWCF.git Fix legacy i18n value handling in i18n form fields Close #3122 --- diff --git a/com.woltlab.wcf/templates/__textFormField.tpl b/com.woltlab.wcf/templates/__textFormField.tpl index 44a3cda275..8d73e00153 100644 --- a/com.woltlab.wcf/templates/__textFormField.tpl +++ b/com.woltlab.wcf/templates/__textFormField.tpl @@ -1,7 +1,7 @@ isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* diff --git a/wcfsetup/install/files/acp/templates/__textFormField.tpl b/wcfsetup/install/files/acp/templates/__textFormField.tpl index 44a3cda275..8d73e00153 100644 --- a/wcfsetup/install/files/acp/templates/__textFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__textFormField.tpl @@ -1,7 +1,7 @@ isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php index 8546b03e26..7c433d646d 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php @@ -7,7 +7,9 @@ use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\IFormDocument; use wcf\system\form\builder\IFormNode; use wcf\system\language\I18nHandler; +use wcf\system\language\LanguageFactory; use wcf\system\Regex; +use wcf\system\WCF; use wcf\util\ArrayUtil; use wcf\util\StringUtil; @@ -120,7 +122,19 @@ trait TI18nFormField { return I18nHandler::getInstance()->getValue($this->getPrefixedId()); } else if ($this->hasI18nValues()) { - return I18nHandler::getInstance()->getValues($this->getPrefixedId()); + $values = I18nHandler::getInstance()->getValues($this->getPrefixedId()); + + // handle legacy values from the past when multilingual values + // were available + if (count(LanguageFactory::getInstance()->getLanguages()) === 1) { + if (isset($values[WCF::getLanguage()->languageID])) { + return $values[WCF::getLanguage()->languageID]; + } + + return current($values); + } + + return $values; } return '';