Bug #4051

TagBuilder is not resetted when a view helper is initialized multiple times

Added by Bastian Waidelich about 13 years ago. Updated almost 12 years ago.

Status:
Resolved
Priority:
Must have
Category:
Core
Target version:
Start date:
2009-07-29
Due date:
% Done:

100%

Estimated time:
Has patch:

Description

Since r2895 ViewHelpers that belong to the same ViewHelperNode (inside loops) are only instantiated once. This leads to the side-effect, that $this->tag points to the same reference.
If a tag attribute is set it won't be resetted when initialize() is called.

Example:

<f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">
    <f:link.action class="{f:if('odd' condition='{foo} % 2')}">{foo}</f:link.action>
</f:for>

Expected result:

<a class="odd" href="viewhelpertest/standard">1</a>
<a href="viewhelpertest/standard">2</a>
<a class="odd" href="viewhelpertest/standard">3</a>
<a href="viewhelpertest/standard">4</a>

Actual result:

<a class="odd" href="viewhelpertest/standard">1</a>
<a class="odd" href="viewhelpertest/standard">2</a>
<a class="odd" href="viewhelpertest/standard">3</a>
<a class="odd" href="viewhelpertest/standard">4</a>

Solution:
Reset TagBuilder instance in initialize()

And we should check, whether there are more side-effects!


Files

4051.patch (3.62 KB) 4051.patch Bastian Waidelich, 2009-07-29 14:01

Related issues

Related to TYPO3.Fluid - Bug #3994: Viewhelpers are instanciated multiple times in ViewHelperNodeResolvedSebastian Kurfuerst2009-07-27

Actions

Also available in: Atom PDF