Item8522: ZonePlugin breaks ADDTOHEAD with PublishPlugin

Priority: Urgent
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: PublishPlugin
Reported By: ArthurClemens
Waiting For:
Last Change By: MichaelTempest
Since I have ZonePlugin installed today (because I need an image gallery), PublishPlugin no longer writes ADDTOHEAD or ADDTOZONE blocks. So my publish site is broken.

In is:
    my $addedToHead = $Foswiki::Plugins::SESSION->RENDERHEAD();
    $header =~ s/(<\/head>)/$addedToHead$1/;

-- ArthurClemens - 14 Feb 2010

That looks like it is supposed to break as soon as internals change. If ZonePlugin is merged into the code Foswiki::RENDERHEAD will be replaced & rewritten. Any plugin that hooks into completePageHandler() won't work with PublishPlugin anyway as far as I can see. So is it possible for it to use Foswiki::writeCompletePage() instead or make sure all completePageHandlers are called?

-- MichaelDaum - 14 Feb 2010

This looks like my problem too, on Foswiki 1.1. Error on page is:
ERROR: WebHome not published: Can't locate object method "RENDERHEAD" via package "Foswiki"

-- LarsEik - 10 Oct 2010

I cannot program Perl very good but managed to get this to work, a little help from pharvey.
    # add items ADDTOHEAD
    # only parse the head section
    my ( $header, $footer ) = split( /%TEXT%/, $tmpl );
    #removed: my $addedToHead = $Foswiki::Plugins::SESSION->RENDERHEAD();
    #removed: $header =~ s/(<\/head>)/$addedToHead$1/;
    my $addedToHead = Foswiki::Func::writeHeader();
    $tmpl = $addedToHead . $text . $footer;
To me it looks like a problem with this plugin on Foswiki 1.1. I don't know if this is a good fix or could be committed to svn.

-- LarsEik - 10 Oct 2010

The code causing the problem was added in PublishPlugin:93d089a44337, under Tasks.Item2557, where the developer wrote "PublishPlugin currently does not render the ADDTOHEAD macro to html."

In 1.0.x, $Foswiki::Plugins::SESSION->RENDERHEAD() does something quite different to Foswiki::Func::writeHeader() - I cannot see that it does anything to ADDTOHEAD stuff. 1.1's Foswiki::Func::writeHeader() should behave the same as it did in 1.0.x, so Lars's patch is probably not correct.

It might be helpful to call the completePageHandlers, but I do not see how that would cause the ADDTOHEAD stuff to be rendered.

I don't think Foswiki::writeCompletePage() will do what is needed on 1.1. I am concerned about this comment at the end of that function:
# SMELL: null operation. the http headers are written out
# during Foswiki::Engine::finalize
# $hdr = $this->{response}->printHeaders;
That suggests to me that the plugin would have to muck with the engine, or else do stuff that the engine normally does, which means it is liable to break again.

Assuming that is not a problem (which I am not convinced is reasonable), it might be an idea to change the plugin to provide a custom "response" object to catch the $this->{response}->print($text); at the end of Foswiki::writeCompletePage().

I am going to revert PublishPlugin:93d089a44337 locally, to see if the plugin will run on 1.1.

-- MichaelTempest - 13 Oct 2010

If I also make the change described in Item9827, then PublishPlugin works on 1.1, but obviously the problem that was fixed in Item2557 reappears.

I would welcome feedback and guidance on how to address the Item2557 problem in 1.1.

-- MichaelTempest - 14 Oct 2010

It now works on the 1.1 branch, and on 1.0.x with and without ZonePlugin.

-- MichaelTempest - 24 Oct 2010

I must still update the change history, also for Item1638.

-- MichaelTempest - 25 Oct 2010

ItemTemplate edit

Summary ZonePlugin breaks ADDTOHEAD with PublishPlugin
ReportedBy ArthurClemens
SVN Range
AppliesTo Extension
Component PublishPlugin
Priority Urgent
CurrentState Closed
Checkins PublishPlugin:effc8fdfdce3 PublishPlugin:5875b3a2f37d
TargetRelease n/a
ReleasedIn n/a
Topic revision: r10 - 29 Oct 2010, MichaelTempest
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