Bug #83667

Language menu is displayed for new (unsaved) records

Added by Surena Golijani over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2018-01-24
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

How to reproduce the bug with tt_news records as an example (the Bug is caused by the EditDocumentController independent from the type of the record being edited):
  • 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
Bugfix:
  • 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

History

#1 Updated by Susanne Moog over 1 year ago

  • Category set to FormEngine aka TCEforms

Also available in: Atom PDF