[BUGFIX] Restore registers before early returns 80/28280/3
authorJo Hasenau <info@cybercraft.de>
Tue, 11 Mar 2014 22:34:04 +0000 (23:34 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 13 May 2014 17:32:25 +0000 (19:32 +0200)
Having an empty image list or a list of images with empty values
will not restore the loaded registers.
So we must restore the registers before any return.

Additionally, the $conf array does not need to contain any
values when calling RESTORE_REGISTER, since it won't handle
parameters anyway, so parameters would just waste memory.

Resolves: #56796
Releases: 6.2
Change-Id: I3e81c614b5c37a14da4b97e18a310e202ae7b766
Reviewed-on: https://review.typo3.org/28280
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Jo Hasenau
Tested-by: Jo Hasenau
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 9dd4070..0eb388d 100644 (file)
@@ -471,7 +471,9 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                if (!$renderMethod || $renderMethod == 'table') {
                        return $this->cObj->IMGTEXT($conf);
                }
+               $restoreRegisters = FALSE;
                if (isset($conf['preRenderRegisters.'])) {
+                       $restoreRegisters = TRUE;
                        $this->cObj->LOAD_REGISTER($conf['preRenderRegisters.'], 'LOAD_REGISTER');
                }
                // Specific configuration for the chosen rendering method
@@ -485,11 +487,17 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                $imgList = trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.']));
                if (!$imgList) {
                        // No images, that's easy
+                       if ($restoreRegisters) {
+                               $this->cObj->LOAD_REGISTER(array(), 'RESTORE_REGISTER');
+                       }
                        return $content;
                }
                $imgs = GeneralUtility::trimExplode(',', $imgList, TRUE);
                if (count($imgs) === 0) {
                        // The imgList was not empty but did only contain empty values
+                       if ($restoreRegisters) {
+                               $this->cObj->LOAD_REGISTER(array(), 'RESTORE_REGISTER');
+                       }
                        return $content;
                }
                $imgStart = (int)$this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.']);
@@ -1080,8 +1088,8 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        $this->cObj->cObjGetSingle($conf['layout'], $conf['layout.'])
                );
 
-               if (isset($conf['preRenderRegisters.'])) {
-                       $this->cObj->LOAD_REGISTER($conf['preRenderRegisters.'], 'RESTORE_REGISTER');
+               if ($restoreRegisters) {
+                       $this->cObj->LOAD_REGISTER(array(), 'RESTORE_REGISTER');
                }
 
                return $output;
index 8b32c41..a7234bd 100644 (file)
@@ -1049,7 +1049,7 @@ class ContentObjectRenderer {
         */
        public function LOAD_REGISTER($conf, $name) {
                if ($name === 'RESTORE_REGISTER') {
-                       return $this->getContentObject('RESTORE_REGISTER')->render($conf);
+                       return $this->getContentObject('RESTORE_REGISTER')->render();
                } else {
                        return $this->getContentObject('LOAD_REGISTER')->render($conf);
                }