ob_gzhandler conflicts with zlib in WordPress — updated

A while back, I posted a rather foolish way to fix the following error message that WordPress likes to cause on my system:

[Sun Jul 01 02:52:49 2007] [error] [client 0.0.0.0] PHP Warning: ob_start() [<a href='ref.outcontrol'>ref.outcontrol</a>]: output handler ‘ob_gzhandler’ conflicts with ‘zlib output compression’ in /home/web/html/blog/wp-includes/functions.php on line 419

Well, the real problem is that WordPress is hard coded to use ob_gzhandler when you select the “” option (in the dashboard under: Options -> Reading). However, you’ve also got some other global zlib compression enabled in your php.ini or possibly your .htaccess. In other words, PHP is being told to compress things twice — which it won’t do and instead spits out the message above.

The fix is to disable one of the compression settings. In my case, I chose to keep the global compression setting in php.ini since I have other applications that it helps with. A quick disabling of WordPress’s compression option and the message is gone.

While on the topic, I’ve noticed that ‘zlib.output_compression really’ doesn’t play nicely with Gallery2 or WordPress. In G2, I randomly get a large font size for most of the page and doing a reload usually clears it up. In WP, sometimes only the masthead shows up and Firefox won’t display the rest of the content even though it’s obviously loading it. <wild_speculation> I’m guess there’s a race condition in the PHP and/or CSS that’s causing this when it goes through the zlip output handler </wild_speculation>. So far, I’m getting much better results with ob_gzhandler. To enable this, in your php.ini add:

output_handler = ob_gzhandler

Don’t forget to turn off zlib.output_compression

zlib.output_compression = off

Update: And, as if that wasn’t enough goofing off for one day, the final solution I used was to take advantage of Apache’s mod_deflate and disable all output buffering and compression entirely in PHP. This way, all content that is compressible gets it, not just PHP stuffs. I suggest reading the above link to the Apache documention, but this is what I put in my httpd.conf which is remarkably similar to the recommendation:

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don’t compress images and other non-compressables
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|mp3|zip|tgz)$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

1 comment to ob_gzhandler conflicts with zlib in WordPress — updated

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*