Issue Bug Closed

#101401Undefined array key "ui" in vendor/typo3/cms-rte-ckeditor/Classes/Form/Element/RichTextElement.php

Georg Tiefenbrunn 07/20/23, 18:28 updated 07/09/24, 14:15

Description

Revision 44d96519 added two unchecked array key access (RichTextElement.php L193 and L198)

        $uiLanguage = $ckeditorConfiguration['options']['language']['ui'];
        if ($this->translationExists($uiLanguage)) {
            $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/ckeditor5/translations/' . $uiLanguage . '.js');
        }

        $contentLanguage = $ckeditorConfiguration['options']['language']['content'];
        if ($this->translationExists($contentLanguage)) {
            $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/ckeditor5/translations/' . $contentLanguage . '.js');
        }

$ckeditorConfiguration is generated in RichTextElement::prepareConfigurationForEditor() and is based on the editor.config array from the RTE yaml files.

CKeditor’s text part language feature uses the config.language.textPartLanguage configuration option. This feature is currently missing (see #101128), but if configured in RTE yaml causes prepareConfigurationForEditor() to assume the UI language of the editor if hard-coded (empty($configuration['language']) is checked instead of empty($configuration['language']['ui'] ?? null)).

RTE configuration causing exception

editor:
  config:
    language:
      textPartLanguage:
        - { title: 'English', languageCode: 'en' }
        - { title: 'French', languageCode: 'fr' }
        - { title: 'German', languageCode: 'de' }

Workaround

editor:
  config:
    language:
      # Use hard-coded UI language
      ui: en
      textPartLanguage:
        - { title: 'English', languageCode: 'en' }
        - { title: 'French', languageCode: 'fr' }
        - { title: 'German', languageCode: 'de' }

Reviews 2