Issue Bug Closed

#88440Recursive calls to section with nested viewhelper yield unexpected results

Philipp Kerling 05/26/19, 13:06 updated 03/30/25, 09:45

Description

Consider the following fluid template:

<f:section name="Test">
    <f:link.external uri="{testVar}">
        {testVar}
        <f:if condition="{testVar} == 'outer'">
            <f:render section="Test" arguments="{testVar: 'inner'}" />
        </f:if>
    </f:link.external>
</f:section>
<f:render section="Test" arguments="{testVar: 'outer'}" />

Normally, you would expect it to render as follows:

<a href="http://outer">
    outer
    <a href="http://inner">
        inner
    </a>
</a>

But it renders like this instead:

<a href="http://inner">
    outer
    <a href="http://inner">
        inner
    </a>
</a>

The reason seems to be that Fluid reuses view helper instances, so the two usages of f:link.external are effectively the same instance, overwriting the arguments.

Do note that the f:link.external is just an example and obviously does not make much sense (in practical terms), but it was just one of the few view helpers that wrap something (condition for this bug to trigger – the recursive call has to be inside the viewhelper content) that I found in core fluid. I usually encounter this issue when rendering menus recursively.

Related: https://github.com/FluidTYPO3/vhs/issues/846

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.