You are here: Foswiki>Tasks Web>Item913 (29 Nov 2009, KennethLavrsen)Edit Attach

Item913: JSCalendarContrib::addHEAD or Func::addToHEAD used in any xxxTagsHandler and in some cases ADDTOHEAD causes deep recursion

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.1, 1.0.8
Target Release: patch
Applies To: Engine
Component: Func::addToHEAD
Branches:
Reported By: KennethLavrsen
Waiting For:
Last Change By: KennethLavrsen
Foswiki::Contrib::JSCalendarContrib::addHEAD cannot be used in beforeCommonTagsHandler, commonTagsHandler, or afterCommonTagsHandler

The contrib help text says it can but this is not true

The loops happens like this

We are in a plugin in commonTagsHandler for example.

We call Foswiki::Contrib::JSCalendarContrib::addHEAD

Inside this we call again Foswiki::Func::addToHEAD

The Foswiki::Func::addToHEAD contains a call to Foswiki.pm's addToHead

This again calls local function handleCommonTags

And part of this is to call among others commonTagsHandler

commonTagsHandler again calls Foswiki::Contrib::JSCalendarContrib::addHEAD

And then we loop again and again and again until we run out of memory.

We need the Foswiki::Contrib::JSCalendarContrib::addHEAD to not be called more than once per plugin but we need to do it without using a global variable as such a variable will fail in mod_perl.

As work around calling from e.g. postRenderingHandler can do the job.

-- KennethLavrsen - 30 Jan 2009

I think I have a solution

I will ask in the #foswiki if my approach is OK but for now assume that I fix this

-- KennethLavrsen - 30 Jan 2009

Also the Foswiki::Func::addToHEAD loops so you cannot use that in commonTagsHandler either.

SO it is there we need to break the loop. I have an idea

-- KennethLavrsen - 30 Jan 2009

I added a prevention against re-entry of Foswiki::Func::addToHEAD.

This also prevents ...JSCalendarContrib::addHEAD from deep recursing.

I still consider adding this type of protection also to ...JSCalendarContrib::addHEAD because it is an awful waste of CPU that is used to call this function easily 20-30 times in vain.

-- KennethLavrsen - 31 Jan 2009

I reopened this task to document the new field in the session object.

-- GilmarSantosJr - 31 Jan 2009

As far as I see the deep recursion fix must go one level deeper right into Foswiki::addToHEAD. That's where the recursion happens. This will protect against all deep recursion triggers, even those done by ADDTOHEAD itself via its topic param.

Reopening and marking urgent. Too bad the former fix wasn't done properly.

-- MichaelDaum - 16 Oct 2009

Ported to release branch. Applied Michael's backport patch.

-- KennethLavrsen - 17 Oct 2009

ItemTemplate edit

Summary JSCalendarContrib::addHEAD or Func::addToHEAD used in any xxxTagsHandler and in some cases ADDTOHEAD causes deep recursion
ReportedBy KennethLavrsen
Codebase 1.0.0, trunk
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component Func::addToHEAD
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:740d454d5e5d distro:302b7394f433 distro:f4133fab4d38 distro:92413191b4c4
TargetRelease patch
ReleasedIn 1.0.1, 1.0.8
Topic revision: r15 - 29 Nov 2009, KennethLavrsen
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