[pmwiki-devel] Pmwiki bug in SideBars (Pm?)

Patrick R. Michaud pmichaud at pobox.com
Fri Nov 24 15:39:18 CST 2006


On Mon, Nov 20, 2006 at 09:50:29AM -0500, The Editor wrote:
> I'm convinced it is something that has to do with the Sidebar.  I just
> get these warnings when there's a zap form in the sidebar.  They clear
> up when I disable that form.  No problems elsewhere.  Even with two
> forms on one part of a page!  Just the sidebar.  Oh, it also never
> happens on my home system, just my server...
> ...
> Thanks so much in advance for help with this.  Pm--could it be a PmWiki bug?

It's not a PmWiki bug, or at least PmWiki is working exactly
as designed.

The error message you're getting is:

> > > Warning: session_start() [function.session-start]: Cannot send session
> > > cookie - headers already sent by (output started at
> > > /home/fastst/public_html/zap/pmwiki.php:951) in
> > > /home/fastst/public_html/zap/cookbook/zap.php on line 452

The problem is that your zap form markup is issuing a session_start()
command after the page output begins.  If a session_start()
takes place, it has to happen before any HTML output, because
PHP sessions need to send a Set-Cookie: HTTP header (and all HTTP
headers have to be sent before any HTML output). 

The reason why it's working when the form is in the main page
text is because PmWiki processes the main text prior to
sending any output.  (It has to do this in order to
be able to set HTTP headers, the <title> tag, etc.)

However, any items coming from the page template, such
as the SideBars, are processed *as* the template is being
output.  In other words, by the time PmWiki gets around
to processing Site.SideBar, it's already started to output
the page contents and it's too late to do anything with
the HTTP headers (such as start a session).

PmWiki never runs into this problem because PmWiki never
initiates a new PHP session as part of markup.

I don't have a good answer for this at the moment, 
other than to perhaps suggest that the ZAP recipe should
always start a session when it's loaded, instead of waiting 
for the markup to be processed.  (However, I recognize this 
isn't always a desirable way to do things.)

One approach we might look at is to have PmWiki process
all of the sidebars and other template directives before
displaying any of them.  But this has its own set of
issues, since many sites will have created <!--function:...-->
directives that expect to be called at the appropriate point
in the template, and therefore use print/echo statements.
I know that a few of my templates do this.  So, we can't
just reorder the output sequence willy-nilly here, we have
to be careful about what we break in the process.

Pm



More information about the pmwiki-devel mailing list