[BUGFIX] Serialize expression in switch viewhelper 04/30804/4
authorBjörn Fromme <mail@bjo3rn.com>
Wed, 18 Jun 2014 08:25:46 +0000 (10:25 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 14 Dec 2014 17:06:03 +0000 (18:06 +0100)
The f:switch ViewHelper breaks with Fluid error "No value found for key
"TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper->switchExpression", thus
the key cannot be removed." for a NULL expression. This patch serializes
the expression before storing it in the ViewHelper variable container.

Resolves: #59255
Releases: master, 6.2
Change-Id: I6eb646bbe4c9975edff0128479e8c057395df5a1
Reviewed-on: http://review.typo3.org/30804
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/ViewHelpers/CaseViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/SwitchViewHelper.php

index 35ddb62..b586bb5 100644 (file)
@@ -36,7 +36,7 @@ class CaseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
                if (is_null($value) && $default === FALSE) {
                        throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('The case View helper must have either value or default argument', 1382867521);
                }
-               $switchExpression = $viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression');
+               $switchExpression = unserialize($viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression'));
 
                // non-type-safe comparison by intention
                if ($default === TRUE || $switchExpression == $value) {
index 9a9b560..ec6f602 100644 (file)
@@ -74,7 +74,7 @@ class SwitchViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelp
                $this->backupSwitchState();
                $templateVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
 
-               $templateVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression', $expression);
+               $templateVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression', serialize($expression));
                $templateVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper::class, 'break', FALSE);
 
                foreach ($this->childNodes as $childNode) {