If your scripts suddenly stops working after upgrading to PHP 5.2.2 and you’re using $GLOBALS['HTTP_RAW_POST_DATA'] then be aware that there’s a bug causing that variable to not be automatically populated. The fix is simple, one just has to do it manually instead (see the bug report). The bug is rather unexpected though, and can therefore take a while to find.

This bug for instance affects the XML-RPC for PHP project which I use in DKP Log Parser. I have posted a patch for fixing the bug in the library.

Gzip in PHP

December 30th, 2006

Use gzencode if you want to interoperate with gnu’s gzip, Java and others. There is no gzdecode, but it’s easy to create. Just take something encoded with gzencode, chop of the first 10 characters and then use gzinflate.

function gzdecode($string) {
    $string = substr($string, 10);
    return gzinflate($string);
}

PHP 5.2: compatibility problems

December 26th, 2006

Upgrading from PHP 5.1 to PHP 5.2 comes with a nasty surprise as I experienced earlier. The problem manifests itself as the following error message.

Catchable fatal error: Object of class foo could not be converted to string in [location] on line 17

To fix is to add a __toString() method to class foo.