[BUGFIX] Fix possible language handling issue 64/27664/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Sun, 1 Sep 2013 11:01:49 +0000 (13:01 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Fri, 21 Feb 2014 09:37:19 +0000 (10:37 +0100)
The language initialization process is currently split in two main
methods (TypoScriptFrontendController->initLLvars and ->settingLanguage).

Only settingLanguage contains hooks and sets the "sys_language_uid"
property (and "sys_language_content") which determine the displayed
records in Frontend. On the opposite, initLLvars is not hookable and sets
the "lang" property, which may be used by charset conversion methods.

In order to determine display language within hooks, the only way
currently is to call initLLvars a second time after determining language,
but this method populates the "languageDependencies" property without
initializing it. So it is filled two times, which leads to incorrect
labels, especially if the displayed language is English and the
default language is not English (as "languageDependencies" is already
filled with "default language").

The three parts of the patch are:
 * The initLLvars method now pre-initializes the "languageDependencies"
   property.
 * The initLLvars is now called from "settingLanguage" method, right
   after the "settingLanguage_preProcess" hook to avoid a second call it.
 * The convPOSTCharset call is now moved after the language
   initialization, as the language determination done by initLLvars
   can have some impact on charset handling (multi-charset locallang.php
   legacy).

Change-Id: I6924345931342d5114b13e5d6fab417387559b9a
Resolves: #49499
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/27664
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 8f1c97e..e400b0b 100644 (file)
@@ -167,13 +167,13 @@ $TT->pull();
 // Get config if not already gotten
 // After this, we should have a valid config-array ready
 $TSFE->getConfigArray();
-// Convert POST data to internal "renderCharset" if different from the metaCharset
-$TSFE->convPOSTCharset();
 // Setting language and locale
 $TT->push('Setting language and locale', '');
 $TSFE->settingLanguage();
 $TSFE->settingLocale();
 $TT->pull();
+// Convert POST data to internal "renderCharset" if different from the metaCharset
+$TSFE->convPOSTCharset();
 // Check JumpUrl
 $TSFE->setExternalJumpUrl();
 $TSFE->checkJumpUrlReferer();
index 7255e20..b2a7a57 100644 (file)
@@ -2415,8 +2415,7 @@ class TypoScriptFrontendController {
                                }
                        }
                }
-               // Initialize charset settings etc.
-               $this->initLLvars();
+
                // No cache
                // Set $this->no_cache TRUE if the config.no_cache value is set!
                if ($this->config['config']['no_cache']) {
@@ -2497,6 +2496,10 @@ class TypoScriptFrontendController {
                                \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this);
                        }
                }
+
+               // Initialize charset settings etc.
+               $this->initLLvars();
+
                // Get values from TypoScript:
                $this->sys_language_uid = ($this->sys_language_content = intval($this->config['config']['sys_language_uid']));
                list($this->sys_language_mode, $sys_language_content) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';', $this->config['config']['sys_language_mode']);
@@ -4694,6 +4697,8 @@ if (version == "n3") {
         * @todo Define visibility
         */
        public function initLLvars() {
+               // Init languageDependencies list
+               $this->languageDependencies = array();
                // Setting language key and split index:
                $this->lang = $this->config['config']['language'] ? $this->config['config']['language'] : 'default';
                $this->getPageRenderer()->setLanguage($this->lang);