Skip to content

AbstractConditionViewHelper should not use ViewHelper name to decide if a childNode is a "then" or "else" node #1053

@sascha-egerer

Description

@sascha-egerer

Currently, the AbstractConditionViewHelper relies on the ending of the viewhelper name if it is a "then" or "else" node.

if ($childNode instanceof ViewHelperNode
&& str_ends_with($childNode->getViewHelperClassName(), 'ThenViewHelper')) {
$data = $childNode->evaluateChildNodes($this->renderingContext);
return $data;
}
if ($childNode instanceof ViewHelperNode
&& str_ends_with($childNode->getViewHelperClassName(), 'ElseViewHelper')) {
$elseViewHelperEncountered = true;
}

This could produce unexpected side effects as a "WhatElseViewHelper" would be interpreted as an else node but is actually just a normal viewhelper.
Possible test case could be (I’ve not really validated the faulty behaviour yet but just stumbled over the code in #1052 (comment)).

<f:if condition="{verdict}">
   <my:whatElse>hello<my:whatElse>
</f:if>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions