headers already sent ...

cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Sun, 2005-08-07 16:13

Since Gallery2 beta4 I get a PHP warning "Cannot modify header information - headers already sent" after calling GalleryEmbed::handleRequest().

It seems that during the execution of GalleryEmbed::handleRequest() PHP's header function gets called, so that the CMS application is not able to send its own HTTP header info afterwards.

Also RC1 seems to behave like that.

Thanks for any help,
Christian

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-08-07 16:34

yes, G2 calls header() multiple times.
yes, you can call header() for the same header multiple times.

but once you've started outputting (e.g. print / echo, ..), you can't call the header() function anymore.

do you get the warning in all G2 pages. and what integration are you talking about?

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Sun, 2005-08-07 17:06

I'm integrating G2 into PmWiki ... this is really strange, since when looking at the PmWiki code, there should be no output before calling GalleryEmbed::HandleRequest(). I'll have to debug that further before I can say where exactly the problem is.

It probably doesn't help you further, but here is the link to the page generating the PHP warning message:

http://www.schlatter.net/pmwikitest/pmwiki.php?n=Main.Gallery

Thanks,
Christian

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-08-08 22:02

... still debugging :-?

It seems that I'm not the only one with this "headers already sent" problem. There are forum threads describing exactly the same problem for mambo + g2 or xaraya + g2.

What I found out so far:

The PHP error message "Warning: Cannot modify header information - headers already sent in /opt/pmwiki-2.0.beta54/pmwiki.php on line 705" seems to be wrong (using Apache2/PHP5). The error message includes the location of the header(..) function call causing the warning, but not the code that sent the headers already or where the output of the script started.

I played with ob_start() / ob_end_flush() and it seems that G2 embedded does not output anything that could cause PHP to send the HTTP headers.

The error/warning happens as soon as the CMS executes its own header(..) calls.

So are there some strange header(..) calls in G2 (embedded) that cannot be modified by later header(..) calls? It would help me a lot if someone could point out how the header(..) calls of G2 embedded look like (I already tried the PHP headers_sent function, but without success).

I'm also quite sure that the problem was introduced with g2 beta4.

Thanks for any help,
Christian

[/list]

 
elarkin

Joined: 2005-02-08
Posts: 18
Posted: Tue, 2005-08-09 13:56

+5 Insightful has seemed to fix the header problem for me, I got the code from J.P. Mullans page before insightful was released, set it up with Xaraya on a fresh build of Gentoo Linux, apache2, Php 4.11, and Mysql.

http://Larkin.home.kg

Its built into xaraya which had its own issues with the new PHP release.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-08-09 13:56

l'll have to debug this asap.

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Fri, 2005-08-12 11:37

valiant, thanks a lot for the header fix. I've installed today the nightly snapshot of 8/12/05 and the PHP warning has gone.

Thanks again,
Christian