[BUGFIX] Image viewhelper clears $GLOBALS['TSFE'] in backend context
authorStefan Froemken <froemken@gmail.com>
Fri, 30 Nov 2012 20:41:59 +0000 (21:41 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Sun, 2 Dec 2012 09:48:33 +0000 (10:48 +0100)
The image viewhelper replaces the $GLOBALS['TSFE'] array to
simulateFrontendEnvironment if it is called in backend context.
After successful get of the image, it restores the TSFE.

But in case, that the requested image has not been found,
it throws an Tx_Fluid_Core_ViewHelper_Exception, which means
that the TSFE get not restored. This causes errors when other
code tries to access TSFE after the image viewhelper has been
executed.

Resolves: #43446
Releases: 4.5, 4.6, 4.7, 6.0

Change-Id: Ic5b1fc73c74ffa7fca6e36c6f42e3f2084efa7c8
Reviewed-on: http://review.typo3.org/16933
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php

index f7f91d5..d8ba0b9 100644 (file)
@@ -124,6 +124,9 @@ class ImageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedV
                $imageInfo = $this->contentObject->getImgResource($src, $setup);
                $GLOBALS['TSFE']->lastImageInfo = $imageInfo;
                if (!is_array($imageInfo)) {
                $imageInfo = $this->contentObject->getImgResource($src, $setup);
                $GLOBALS['TSFE']->lastImageInfo = $imageInfo;
                if (!is_array($imageInfo)) {
+                       if (TYPO3_MODE === 'BE') {
+                               $this->resetFrontendEnvironment();
+                       }
                        throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
                }
                $imageInfo[3] = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
                        throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
                }
                $imageInfo[3] = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);