Upgrading AlanHogan.com to PHP 8.1

This website runs my own content management system. Previously I wrote about upgrading it from PHP 5.6 to PHP 7.

Now I have managed to upgrade it to PHP 8.1 as well.


First, I upgraded my staging site to run PHP 8.1. It failed badly — but I checked the error logs. It became clear that language changes had resulted in code in some of the libraries I am using (open-source code) was no longer compatible.

One such library was ADOdb_lite, an abandoned project. But that was not a big deal. ADOdb_lite had the same API as the larger project ADOdb, which, luck would have it, is still maintained as I write this.

The other incompatibility was PHP Markdown, which is also still maintained. Thus, all I had to do was replace my version with the latest.

And that was it. My site was 100% functional on PHP 8.1!

Well, at least, as far as I could tell. A later look at my error logs showed that I was using an obsolete function in part of the code path of my popular online MIPS assembler and the corresponding MIPS simulator. The functionality of the obsolete function isn't needed in newer versions of PHP, so the fix was simple. I just added a check to see if the function exists before calling it.

That was all I needed to do. However, my error logs were still showing warnings about undefined variables and undefined array keys. These did not indicate bugs or incompatibilities (at least not necessarily), but nevertheless I added a few isset() calls, ensuring the variables and array keys I was accessing really did exist first. This, if nothing else, helped tidy up the error log, reducing noise.

I want to give a big shout-out to Michel Fortin, maintainer of PHP Markdown, for being a great maintainer. Same to Damien Regad and Mark Newnham of ADOdb, who took over from the similarly great John Lim. It's thanks to these open-source maintainers that I have been able to keep my aging website online over the years with minimal maintenance effort.

April 8th, 2022
Alan Hogan (@alanhogan_com).  Contact · About