Issue Bug Closed

#61999Small bug in sysext/lang/Classes/LanguageService.php

Thomas Candrian 10/02/14, 01:35 updated 10/02/18, 11:51

Description

In sysext/lang/Classes/LanguageService.php line 233 (TYPO3 6.2.5):

    public function getLL($index, $hsc = FALSE) {
            // Get Local Language
        if (isset($GLOBALS['LOCAL_LANG'][$this->lang][$index][0]['target'])) {
            $output = $GLOBALS['LOCAL_LANG'][$this->lang][$index][0]['target'];
        } else {
            $output = $GLOBALS['LOCAL_LANG']['default'][$index][0]['target'];
        }

may fail if $index is not set to an existing element of the array. Better would be something like this (or even better an appropriate error handling ?!?):

    public function getLL($index, $hsc = FALSE) {
            // Get Local Language
        if (isset($GLOBALS['LOCAL_LANG'][$this->lang][$index][0]['target'])) {
            $output = $GLOBALS['LOCAL_LANG'][$this->lang][$index][0]['target'];
        } else {
            if (!isset($GLOBALS['LOCAL_LANG']['default'][$index][0]['target'])){
                $output = "??";
            } else {
                $output = $GLOBALS['LOCAL_LANG']['default'][$index][0]['target'];
            }
        }

Reviews 1