#83667Language menu is displayed for new (unsaved) records
Description
Language menu is displayed for new (unsaved) records, showing faulty select options
The bug is caused by the EditDocumentController not checking if any data is loaded for the current record, which is not the case if a new and unsaved record is edited.
The EditDocumentController continues to build the language menu, although the context in which it is build is faulty because of the missing data.
- create a tt_news record in a non-default language (field sys_language_uid>0) without any original record set (field l18n_parent=0)
- create a new tt_news record: the language menu is shown with the single entry of the language of the above record
- add condition to avoid building the language menu if no data is loaded for the current record
- typo3/sysext/backend/Classes/Controller/EditDocumentController.php languageSwitch():
if (is_array($langRows) && count($langRows) > 1) {
$rowsByLang = [];
$fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField;
// Get record in current language
$rowCurrent = BackendUtility::getLiveVersionOfRecord($table, $uid, $fetchFields);
if (!is_array($rowCurrent)) {
$rowCurrent = BackendUtility::getRecord($table, $uid, $fetchFields);
}
/**
* BUGFIX START
*/
if (is_array($rowCurrent)) {
/**
* BUGFIX END
*/
$currentLanguage = (int)$rowCurrent[$languageField];
// Disabled for records with [all] language!
if ($currentLanguage > -1) {
Affected TYPO3 versions: at least 7 & 8
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.