[BUGFIX] Fatal error in PageRenderer 48/44048/2
authorEric Chavaillaz <eric@hemmer.ch>
Wed, 14 Oct 2015 09:39:34 +0000 (11:39 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 15 Oct 2015 19:01:32 +0000 (21:01 +0200)
When calling page.inlineLanguageLabel in TypoScript,
it results with a fatal error in the frontend because
in PageRenderer there is no check of the TYPO3 mode.

Resolves: #70681
Releases: master
Change-Id: I3b2e9bf28bcfce799fb3b90fa404d6b6986ce464
Reviewed-on: http://review.typo3.org/44048
Reviewed-by: Marcus Schwemer <ms@schwemer.de>
Tested-by: Marcus Schwemer <ms@schwemer.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Page/PageRenderer.php

index 1026f2f..181d050 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
  * TYPO3 pageRender class (new in TYPO3 4.3.0)
@@ -1313,13 +1314,13 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
         // Add language labels for ExtDirect
         if (TYPO3_MODE === 'FE') {
             $this->addInlineLanguageLabelArray(array(
-                'extDirect_timeoutHeader' => $GLOBALS['TSFE']->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutHeader'),
-                'extDirect_timeoutMessage' => $GLOBALS['TSFE']->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutMessage')
+                'extDirect_timeoutHeader' => $this->getTypoScriptFrontendController()->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutHeader'),
+                'extDirect_timeoutMessage' => $this->getTypoScriptFrontendController()->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutMessage')
             ));
         } else {
             $this->addInlineLanguageLabelArray(array(
-                'extDirect_timeoutHeader' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutHeader'),
-                'extDirect_timeoutMessage' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutMessage')
+                'extDirect_timeoutHeader' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutHeader'),
+                'extDirect_timeoutMessage' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_misc.xlf:extDirect_timeoutMessage')
             ));
         }
 
@@ -1693,7 +1694,11 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
     {
         if ($parseWithLanguageService === true) {
             foreach ($array as $key => $value) {
-                $array[$key] = $this->getLanguageService()->sL($value);
+                if (TYPO3_MODE === 'FE') {
+                    $array[$key] = $this->getTypoScriptFrontendController()->sL($value);
+                } else {
+                    $array[$key] = $this->getLanguageService()->sL($value);
+                }
             }
         }
 
@@ -2703,6 +2708,16 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface
     }
 
     /**
+     * Returns global frontend controller
+     *
+     * @return TypoScriptFrontendController
+     */
+    protected function getTypoScriptFrontendController()
+    {
+        return $GLOBALS['TSFE'];
+    }
+
+    /**
      * Returns global language service instance
      *
      * @return \TYPO3\CMS\Lang\LanguageService