PHP 4: Still standing in the doorway, telling everyone it’s leaving

On January 1st of this year, developer support for PHP 4 ended; only PHP 5 is supported these days.

Our system still works with PHP 4, and we still have about 32.5% of our active hosted sites running on PHP 4. But its days are clearly numbered, so we’re taking appropriate, measured steps to curtail PHP 4 support on our network as well. We’ve removed most public references to PHP 4, and using our interface it’s no longer possible to switch a site to PHP 4, only away from it. With that done, we’re not making specific plans to go out and yank PHP 4 out from under our members whose sites are still using it before they are ready.

However, our plans are not the only factor at work. Sooner or later, a security problem or critical bug will emerge with PHP 4 that we won’t be able to fix ourselves or work around. Without developer support, we’ll be out of options. So the same day that happens, every PHP 4 site we host will be upgraded to the then-current version of PHP 5 whether they’re ready or not.

We have no way to predict if or when that will happen. Therefore, if your site is running PHP 4, you should make plans to upgrade your site sometime soon at a time when you’ll be available to handle any issues that arise. The upgrade is pretty straightforward, and problems are fairly rare, but it’s still better to block out a bit of time just in case.

To help people make this move, I want to address three points.

1. What version of PHP is my site running?

To find the version of PHP used by your site, go the site info panel for your site (click on the site name on the Sites tab), and look for the Server Type line in the Config Information box. If it says “Apache 1.3, PHP 4 Fast, CGI” then that site is running PHP 4. If it says PHP 5 Fast or PHP 5 Flex, then you don’t need to worry, because that site is already up-to-date.

2. How do I upgrade my site?

From the same page, select the Change Server Type action from the Actions box. Select the “Apache 1.3, PHP 5 Fast, CGI” radio button, and click the “Save Changes” button. Give it about 5 minutes, and your site should be up and running on PHP 5 with negligible disruption. The actual switchover should be nearly instant, it just sometimes takes a few minutes to process. When upgrading your site, do not accidentally choose the PHP 5 Flex option; it is a special-purpose option that will cause slower performance and much bigger compatibility issues in most cases.

3. What kind of problems could I have when upgrading?

Most people won’t have any problems at all. If you’re running a prewritten application developed by someone else (e.g. WordPress), then just make sure you are running an up-to-date version identified by the developers as working with PHP 5. That’s about it.

For people who program their own sites, we do have a few tips. When we upgraded our own PHP code from PHP 4 to PHP 5, the main thing that bit us was that “public” and “protected” are now reserved words in PHP 5. So, a couple of variable names ($public) had to be changed. There’s also an HTTP extension (pecl_http) we provide with PHP 5 with some common function names that sometimes collide with names others might have used in PHP 4 (http_request, http_get); if your site uses functions with these names, they’ll have to be renamed. We encountered similar issues with a SOAP library provided by our domain registrar for interacting with their system.

There is also some ugly, ugly code floating around that redefines $this inside objects in PHP 4. That should be fixed, because it was a bad idea in the first place. We encountered it in the PEAR Net_DNS module and a couple of other similar places.

The official PHP site provides a helpful list of backward-incompatible changes in PHP 5. In addition to the main content, the comments on that page are also quite helpful.

If people have other tips for migrating from PHP 4 to PHP 5, please feel free to submit them as comments.

But please, if you have a site still running on PHP 4, update it soon, at a time of your choosing, rather than waiting until the choice is taken away.

3 Comments

RSS feed for comments on this post.

  1. Why don’t you offer an option “Copy Site to PHP 5”, where it’ll copy a PHP 4 site to the newer version, have a few hours to test it, and then either upgrade the original or delete the original?

    You could certainly make a copy of a site if you wanted, but due to the complexity of sites and the variety of different configurations, we have no plans to offer such an option. -jdw

    Comment by Foxie — June 9, 2009 #

  2. So how have the numbers changed since you posted this? Still around 30%? I converted all my sites straight away, because PHP4 is arse pudding on toast. One of them wasn’t working, but I fixed it quick enough (it relied on the PHP4 names of some XSLT functions that were replaced in PHP5; no biggie) and now I’m set.

    Of course, I’m looking forward to PHP6, because it has the GOTO command! You can’t write appalling crap anywhere near as easily without it!

    Not much change, yet. We’ve put it on the new “For Your Information…” box. Also, a fair number of those sites probably belong to people using CGI or no programming at all; they probably don’t care too much. -jdw

    Comment by Eric TF Bat — June 25, 2009 #

  3. It would be nice to have some sort of interface that shows you all sites under your NFSN account that are using PHP 4. I have three accounts and over 30 sites. I’ve identified 2 sites that are still running PHP 4, but it would be very useful to go to a page and view what version of PHP I’m using for every site.

    That’s a good idea. We’ll look into it. -jdw

    Comment by Patrick — July 2, 2009 #

Sorry, the comment form is closed at this time.

Entries Feed and comments Feed feeds. Valid XHTML and CSS.
Powered by WordPress. Hosted by NearlyFreeSpeech.NET.

NFSN