Item9480: Foswiki::_renderZone() sometimes renders body/head multiple times
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
Kenneth pointed out that usage of
RenderFormPlugin, which calls
JSCalendarContrib::addHEAD multiple times, results in
JSCalendarContrib's add's being added to both body and head zones.
This only happens for
{OptimizePageLayout} = 0;
--
PaulHarvey - 17 Aug 2010
- The page is built.
Foswiki::writeCompletePage()
is dispatched.
- A call to
Foswiki::_renderZones()
is made.
-
Foswiki::_renderZones()
calls Foswiki::_renderZone()
for the head zone.
- When
{OptimizePageLayout} = 0;
- then this usually renders/flushes both head and body zones
-
Foswiki::_renderZone()
calls Foswiki::Meta::renderTML()
-
Foswiki::Meta::renderTML()
causes RenderFormPlugin::postRenderHandler()
to be dispatched
-
RenderFormPlugin::postRenderHandler()
calls Foswiki::Func::addToZone()
to add content to both head and body zones
-
Foswiki::_renderZones()
calls Foswiki::_renderZone()
for the body zone.
- When
{OptimizePageLayout} = 0;
, normally the body zone is empty. But we render/flush both head and body zones again - and this time there is the content added by RenderFormPlugin::postRenderHandler()
, again.
Options:
- Fix RenderFormPlugin. It should be doing this stuff in initPlugin, not abusing
writeCompletePage()
(I think this is a pre-ADDTOZONE technique)
- Give
Foswiki::_renderZones()
some special logic to detect {OptimizePageLayout} = 0;
and not call _renderZone(body)
in the first place
- Add some sort of counter/state/flag to
Foswiki::_renderZone()
to really ensure body/head zones are only rendered once? No, that's a terrible idea.
Options 1 & 2 seem reasonable to me. Opinions?
--
PaulHarvey - 18 Aug 2010
I added a fix which only caters for the
body
,
head
, and
{OptimizePageLayout} = 0
case.
It's possible that plugins working on their own non-body/head zones could come up against this bug in the same way.
A proper solution might involve new plugin hooks - beforeRenderZone/afterRenderZone, maybe - and a rethink of a what point in the rendering pipeline we call renderTML/expandMacros
--
PaulHarvey - 18 Aug 2010
added
Development.AddToZoneFromPluginHandlers
--
PaulHarvey - 18 Aug 2010
Re-opened to fix a silly mistake affect body zone rendering with
{OptimizePageLayout} = 1
--
PaulHarvey - 22 Aug 2010
Re-opened again to fix the tests :/
--
PaulHarvey - 23 Aug 2010