Horde and PHP5

There have been a few questions regarding the PHP5 compatibility of Horde, IMP, or other applications on the Horde mailing list. Even more people have reported problems with Horde on PHP5 powered servers without even considering that they might be incompatible. Additionally I see some search engine hits on Horde and PHP5 on my website, so here is the complete story.

The quick answer

Horde 2.x, IMP 3.x, and all compatible versions do not work with PHP5 and never will. Horde 3, IMP 4, etc. will be compatible and the current development code of these upcoming versions already seems to work fine with PHP5.

The long answer

Let's start the answer with another question: "The PHP people said that PHP5 is backwards compatible with PHP4 and most PHP4 applications should work with PHP5 without modifications, why doesn't Horde and why can't you simply fix it?"

For one there were a few changes to certain PHP functions or behaviour that either broke backward compatibility with PHP4 or now raise warnings or error messages where they didn't before. Under this category fall array_merge(), now requiring the parameters being arrays, or the usage of $this in statically called methods. These issues can easily be fixed because the error messages are descriptive and immediately visible.

Problematic are the changes in behaviour that happen silently and don't raise error messages. You need to know that Horde and its applications are heavily relying on object-oriented programming features. One of the major changes in PHP5 is that objects are now passed by reference by default and no longer on demand as in PHP4. While this is generally a Good Thing, there are a lot of places in the object oriented libraries of Horde where we explicitely rely on having object copies. Modifying these objects in PHP5 causes unpredictable side-effects because the original objects get changed too.

For that purpose we created a small clone method that works in both PHP4 and PHP5. Unfortunately you can't use a simple search-and-replace to find and fix the places where you need this method though. It would instead require to go through each of the 45,000 lines of code that the stable Horde applications consist of to identify the affected code parts. Or you could simply run the code on PHP5 for a while and fix it when you hit a bug. Both can't be managed by the Horde team at the moment while we're focussing on getting new major versions out of the door. These new versions will be PHP5-compatible because these are what the developers use on a daily basis.