You are here: Foswiki>Tasks Web>Item9480 (23 Aug 2010, PaulHarvey)Edit Attach

Item9480: Foswiki::_renderZone() sometimes renders body/head multiple times

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
Reported By: PaulHarvey
Waiting For: Main.PaulHarvey
Last Change By: PaulHarvey
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

  1. The page is built. Foswiki::writeCompletePage() is dispatched.
    1. A call to Foswiki::_renderZones() is made.
      1. Foswiki::_renderZones() calls Foswiki::_renderZone() for the head zone.
        • When {OptimizePageLayout} = 0; - then this usually renders/flushes both head and body zones
        1. Foswiki::_renderZone() calls Foswiki::Meta::renderTML()
        2. Foswiki::Meta::renderTML() causes RenderFormPlugin::postRenderHandler() to be dispatched
        3. warning RenderFormPlugin::postRenderHandler() calls Foswiki::Func::addToZone() to add content to both head and body zones
      2. Foswiki::_renderZones() calls Foswiki::_renderZone() for the body zone.
        1. warning 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:
  1. Fix RenderFormPlugin. It should be doing this stuff in initPlugin, not abusing writeCompletePage() (I think this is a pre-ADDTOZONE technique)
  2. Give Foswiki::_renderZones() some special logic to detect {OptimizePageLayout} = 0; and not call _renderZone(body) in the first place
  3. 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
 

ItemTemplate edit

Summary Foswiki::_renderZone() sometimes renders body/head multiple times
ReportedBy PaulHarvey
Codebase trunk
SVN Range
AppliesTo Engine
Component
Priority Normal
CurrentState Closed
WaitingFor PaulHarvey
Checkins distro:7001260cbf69 distro:24e5d79f97df distro:71dc5daf40cf distro:584cf697ae51 distro:99e1232755a4
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r11 - 23 Aug 2010, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy