More PHP Woes: PHP 5.2.8 and libxml 2.7.x

EDIT: PHP 5.2.9 is out for FreeBSD, so this may be fixed.

There seems to be a bug in the way PHP’s xml library handles data when compiled against libxml 2.7.x. Supposedly, this will be fixed in the next release of PHP, but for now you have to back down to libxml 2.6.x, or compile against expat instead of libxml.

I first noticed this with a Joomla installation, a component was erroring out, saying “Fatal error: Call to a member function getTagName() on a non-object” (Z Weather, for those interested in knowing). Investigating this led me to this bug entry for PHP. I then found another server of mine with problems, this one was using XMLRPC and was getting back responses stripped of the < and > characters, rendering returned HTML code quite broken.

For those of you on FreeBSD who have no idea how to downgrade to the earlier version, it’s actually pretty simple, it can be done like so:

# cd /usr/ports/ports-mgmt/portdowngrade/
# make DEFAULT_CVS_SERVER="" install clean
# portdowngrade libxml2

When presented with the choice, choose textproc/libxml2 (Probably option #2).
It will then start listing all prior version of the libxml2 port. When you see version 2.6.32, press enter. Use the most recent copy of 2.6.32, for me it was timestamped 2008/11/19 19:23:07.
Press the number (probably 3) at the start of the line for the version you want, and let portdowngrade do its thing. As suggested by the output of portdowngrade, finish up like so:

# portsdb -Uu
# portupgrade -f libxml2
# /usr/local/etc/rc.d/apache22 restart

Be aware that the portsdb -Uu run can take a while on older systems. Also, you may substitute that last line with whatever command you typically use to restart apache (shutdown and start again, not a graceful restart)

Danger Will Robinson!: Note that if you update your ports tree it will bring libxml2 back to the most recent version, be careful not to upgrade it again until after the next release of PHP!

Comments are closed.