[BUGFIX] Creating default object from empty value in AbstractBackendViewHelper
authorPhilipp Gampe <dev@philippgampe.info>
Sun, 2 Sep 2012 09:10:02 +0000 (11:10 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 21 Sep 2012 21:30:11 +0000 (23:30 +0200)
The object `$GLOBALS['SOBE']` is not always set and thus setting a propery fails.

Change-Id: Ic70833516cb34c3ace9b58aaab61fd8887d0fcf6
Fixes: #40519
Releases: 6.0
Reviewed-on: http://review.typo3.org/14280
Reviewed-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/fluid/Classes/ViewHelpers/Be/AbstractBackendViewHelper.php

index 0f0d0a3..d279288 100644 (file)
@@ -34,10 +34,16 @@ abstract class AbstractBackendViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelpe
         */
        public function getDocInstance() {
                if (!isset($GLOBALS['SOBE']->doc)) {
-                       $GLOBALS['SOBE']->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-                       $GLOBALS['SOBE']->doc->backPath = $GLOBALS['BACK_PATH'];
+                       /** @var $doc \TYPO3\CMS\Backend\Template\DocumentTemplate */
+                       $doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
+                       $doc->backPath = $GLOBALS['BACK_PATH'];
+                       if (is_object($GLOBALS['SOBE'])) {
+                               $GLOBALS['SOBE']->doc = $doc;
+                       }
+               } else {
+                       $doc = $GLOBALS['SOBE']->doc;
                }
-               return $GLOBALS['SOBE']->doc;
+               return $doc;
        }
 
 }