The Pencil Guy: Hourann's illogical blog

Fixing WordPress 2.1 + PHP 5 + HTTP 1.0

Saturday 31 March 2007 at 8:03 pm

So I’ve finally figured out the random problems that were plaguing this blog. It all started when I upgraded to PHP 5.2.1, which breaks lots of functions that software like WordPress depends on. The obvious step, which I was silly enough to delay, is to upgrade WordPress and all plugins to their most recent versions, thus making life much easier. (Many plugins are bitten by output buffering changes.)

But I was still having trouble due to this nasty bug, whereby recent versions of PHP plus recent versions of WordPress will cause the output to always be HTTP 1.1. Symptoms include seemingly random hex character strings scattered around your blog (such as when connecting via telnet), or blank pages that only affect some people. This is because HTTP 1.1 features, like the chunked transfer encoding, confuse clients that only speak 1.0 (including many commercial proxy servers and a lot of Python code built on feedparser).

The fix is to edit line 832 in wp-includes/functions.php. Replace this line in the status_header function:

@header("HTTP/1.1 $header $text", true, $header);

with this much happier code:

@header($_SERVER["SERVER_PROTOCOL"]." ".$header." ".$text, true, $header);

Also, I found that upgrading to 2.1 breaks the old version of Jerome’s Keywords, and can unexpectedly change your link category numbers.

Update 16/5: The problem has been fixed in WordPress 2.2. Thanks Ryan!

3 comments »