216334845_821aaf4823_o

WordPress and PHP 5: Be the Change You Want to See

The other day, I wrote the popular 10 Things You Need to Know About WordPress 2.9. As usual, most people are very excited about the new release which is now in beta and available for testing. In the article, I made a few fundamental errors which I have since corrected.

Notably, I mentioned that WordPress 3.0 would be going to PHP 5. This was based on conversations I had with a core developer which I now realized I misunderstood. Kinda. WordPress will probably not be dropping PHP 4 support in WordPress 3.0 but as core developer Mark Jaquith suggests:

Some things already require PHP 5, like time zone support or oEmbed. There are no plans that I know of to remove PHP 4 support in 3.0 “” last I checked we still had 12% of WP installs using PHP 4.

I see more of a natural and gradual deprecation of PHP 4. We’re very much open to making new features require PHP 5 if it would be a pain to make them PHP 4 compatible.

As a PHP developer, I am on board with calls for PHP 5 support. PHP 4 has been end of life (EOL) since August 8, 2008. That basically means that there will be no more releases, no more security patches, no more nothing. It’s done. Stick a fork in it. However, as Matt mentioned on stage at WordCamp NYC this weekend, there are still 12% of WordPress installations using PHP 4 hosting. He breaks that down as approximately 2M installs, the size of a major American city. More precisely, that’s approximately the size of Philadelphia.

This is not to defend WordPress development. I’d leave Philadelphia behind in a minute if I could get access to real object oriented PHP, reliable XML parsing, better HTTP transports and so much more. Yes, Philadelphia… I just threw you under the bus. That’s for signing Mike Vick. However, as Mark suggests, increasingly more features are being added to the core that require PHP 5.

oEmbed, which will ship in WordPress 2.9, requires XML or JSON parsing. XML parsing sucks in PHP 4. JSON ships by default in PHP 5.2. It is easier to backport JSON support to PHP 4 than try to engineer XML parsing for PHP 4. Some in the PHP community feel like backporting a PHP 5 feature to PHP 4 disincentivizes PHP 5 movement. It may, I’m not here to argue that.

Time Zone support is handled via the PHP class DateTimeZone, a PHP 5 class. Of course, on PHP 4 hosts, the user simply has to set the UTC offset (say, UTC-5 for Eastern Standard Time) manually. Graceful degradation.

I personally was one of the first people to write code for the SSH2 portion of the one click automatic upgrade feature. I, of course, did not go very far with it, but I was the one who first took a stab at creating that.

It is not worth it for PHP developers to throw mud at WordPress developers and the PHP 4 requirement if they are not willing to write code to make it better. Writing code does not, of course, mean that your feature will be incorporated. But this is an open source project. If you want to see new features, and the developers have indicated willingness through not only words, but also action, to include PHP 5 features, then you need to be the champion of those changes. In other words, you need to write the code, submit the ticket and state your case. Even if you can’t write the code, open a ticket and be a champion for the case.

Effective arguments, however, do not include holy wars over PHP 4 or PHP 5. Effective arguments do include security, usability, and feature requests that reflect “must have” features. Is it plugin territory or should it be a core feature? Why? State your case.

I will admit not being overly active in the ongoing development of WordPress. I have client work built around WordPress, so that takes up most of my time. Understanding that, I also have no room to throw mud unless I’m willing to step up and write code too. It’s sort of like voting. If I don’t bother to go vote, then I can’t complain about my elected officials.

If you want to see change in WordPress, be that change and put your words into action.

Published by

Aaron Brazell

Aaron Brazell is a Baltimore, MD-based WordPress developer, a co-founder at WP Engine, WordPress core contributor and author. He wrote the book WordPress Bible and has been publishing on the web since 2000. You can follow him on Twitter, on his personal blog and view his photography at The Aperture Filter.

12 thoughts on “WordPress and PHP 5: Be the Change You Want to See”

  1. How’s this:

    In web2project, we’re currently working to be fully PHP 5.3 compatible – handling E_DEPRECATED, updating for E_STRICT, etc – I’ll write up all of the changes that we’ve had to do along with detailed steps and put them on our wiki. Some of it will be patches, some howto’s, and probably other notes. From there, I’ll reach out within the WordPress community and share all of it to see what can be used where.

    As I noted on Twitter… when one of those 2M PHP4 WordPress installations gets hacked, *no one* is going to scream “someone hacked my php!”.

    They’re going to scream “someone hacked my WordPress install!” ;)

      1. Well, the E_DEPRECATED warning is a list of stuff that will *disappear* in PHP6, mostly due to security or performance reasons, etc. So working against that list will make WordPress more secure and faster, give it more time to live on PHP5 without nasty errors that are confusing/scary to most users…and it will make the *next* transition smoother.

        All good things. :)

  2. The PHP4 numbers continue to drop, it’s a matter of time before the full move is made.

    Posts like this will continue to help those efforts, maybe empowering people who otherwise wouldn’t get involved.

    Definitely all good things ;)

  3. The problem with this approach (as we’ve seen in the Joomla community) is that the more code you hack to work under PHP 4, the more code you have to fix in PHP 5 later.

    Why am I not writing patches for WordPress? Because I’m busy writing this patch for Joomla 1.6 so that functions don’t return references: an attempt at saving memory under PHP 4 that’s counter-productive in PHP 5. The Joomla project put an incredible amount of effort into making 1.5 compatible with PHP 4 & 5, which in retrospect was a huge waste of time. There’s no reason for WordPress to repeat this mistake.

    While you might say I’m “throwing mud,” I’d say I’m just speaking from pained experience.

    1. I didn’t think you were throwing mud, Joe. I was looking squarely at Brandon. And to a lesser extent, I was continuing my conversation with Chris Pearson, who develops the Thesis theme, from last week over IM.

  4. Great post Aaron. Funny you should mention this, I brought up the PHP4 issue a little over a month ago over at WP Tavern and a decent discussion ensued.

    The numbers are deceptive. I imagine the vast majority of those users are on shared hosts that are just to lazy to migrate their customers to PHP5. It is highly unlikely WP would lose 12% of its users in this scenario. I am willing to bet 50 – 75% of those users would ask their host to upgrade them to PHP5 if they were presented with a friendly WP error message instructing them to do so.

    1. Agreed. In my experience with Joomla plugins, many people even think they’re already running PHP 5 when they’re actually running 4. In some cases, hosts have offered a choice between the two with PHP 4 as the default.

  5. I can’t see them dropping php4 support just yet. There are loads of casual bloggers out there still on php4 and probably don’t even realise it. Cutting out php4 would cause a whole host of problems overnight.

  6. Excellent advice, it’s similar to elections, don’t complain unless you are willing to make a difference yourself, however, you have a lot of ground to stand on with your immense experience.

  7. Great points Aaron, it is ridiculous to complain about a well designed application and have no community respect and step up to the plate and help. I think WordPress is an amazing application and has excellent programmers, and obviously issues will always arise that need to be addressed.

  8. Aaron, have you considered writing a “Here’s Why You Need to Make Sure Your Web Host is Using PHP 5″ post for someone like Darren Rowse over at ProBlogger? I’m sure it would go a long way towards getting the WordPress community below that 10% PHP 4 margin that Matt, and other developers have suggested, is the tipping point for WordPress moving to PHP 5.

Comments are closed.