Bug #4051
TagBuilder is not resetted when a view helper is initialized multiple times
Status: | Resolved | Start date: | 2009-07-29 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Bastian Waidelich | % Done: | 100% |
|
Category: | Core | |||
Target version: | 1.0.0 alpha 4 | |||
Has patch: | Affected Flow version: |
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!
Related issues
Associated revisions
[+FEATURE] Fluid (ViewHelpers): Added reset() method to TagBuilder. This is called in all TagBasedViewHelper's initialize() method. This resolves #4051.
History
#1 Updated by Bastian Waidelich about 6 years ago
- File 4051.patch added
- Status changed from New to Needs Feedback
- Assigned To set to Robert Lemke
The attached patch fixes the issue for me.
@Robert: Please have a look and commit if there are no objections
#2 Updated by Robert Lemke about 6 years ago
- Target version set to 1.0.0 alpha 3
#3 Updated by Bastian Waidelich almost 6 years ago
- Assigned To changed from Robert Lemke to Bastian Waidelich
#4 Updated by Bastian Waidelich almost 6 years ago
- Status changed from Needs Feedback to Resolved
- % Done changed from 0 to 100
Applied in changeset r3119.
#5 Updated by Robert Lemke almost 6 years ago
- Target version changed from 1.0.0 alpha 3 to 1.0.0 alpha 4