Fluid
Fluid copied to clipboard
AbstractViewHelper::renderChildrenClosure is not reset properly on shared ViewHelpers, causing broken output on first render
Summary
When using a shared ViewHelper with (different) nested content from different partials on a single page, later instances of the ViewHelper incorrectly output the content of previous instances (but only on the first render of a page).
Details
The issue is probably caused because the ViewHelperInvoker
will only update the renderChildrenClosure
of a shared view helper if a new renderChildrenClosure exists (which is not the case if the specific partial has not been rendered yet), see ViewHelperInvoker. This causes the shared ViewHelper to use a 'stale' renderChildrenClosure
from a previous invokation, producing old and incorrect output.
Fix/Workaround
So far we have found (at least) three temporary fixes:
a) Making the ViewHelper in question not shared, e.g. by adding an entry for the specific ViewHelper class to Services.yaml with the property shared: false
b) Manually setting renderChildrenClosure
to null inside the ViewHelper, e.g. in ViewHelper::initialize()
c) (more a workaround than a fix) Creating individual subclasses of the ViewHelper and use them for different nested content.