Friday, July 15, 2011

Un-necessary Deprecation in PHP

This blog is a gripe. A whine. I'm bitching. Just a warning.

Sometimes it is necessary to deprecate functions and change how a programming language works. Other times, it makes little or no sense.

Manuel Lemos of phpclasses.org blogs about a coming change here: The Plot to Kill PHP MySQL Extension. Read his thoughts, they are better phrased than mine.

While not my personal choice, MySQL is without a doubt the most widely used RDBMS in PHP web applications. It has a long history with PHP and numerous web applications currently use the very PHP MySQL Extension that is on the chopping block.

As Manuel points out, there are other ways to connect to MySQL. Many web applications and classes however use the extension that the PHP developers wish to deprecate. Deprecating the PHP MySQL extension is a bonehead move. Are there better ways to do things? Absolutely. Should web developers update their code to use these better methods? Absolutely. Is it still a bone headed move to deprecate it? Absolutely.

From my point of view, the problem is cost. Someone has to go through the code and make all the changes. Then once all the changes have been made, the code has to be tested. If the web application is actively being developed, the developer should update their code base, but not all web applications are actively being developed and there are many cases where using updated versions from the vendor is not easily done.

For example, I use the search engine sphider on some web sites I maintain. I hacked the crap out of it to beef up security, make it output DOMDocument nodes instead of raw HTML, did some major hacks to the admin interface to fit sphider administration into the general web site administration and remove options that would only confuse the non tech people using the admin interface, and some other tweaks.

Sphider (at least the version I started with) uses the very MySQL extension that is on the chopping block. Now I will either need to fix sphider for these web sites, get an updated version of sphider and hack the crap out it as well, or implement a different solution to site search. I like to be a charitable guy, but I do not work for free. All three of those options are going to cost someone some real money when the next version of PHP released and the boss wants to know why the apache log is full of deprecation warnings.

Yes, this highlights the importance of using database abstraction. No, most web applications do not use database abstraction (wish they did, make it easier for me to run stuff on PostgreSQL without needing to hack it) and there are a lot of legacy web applications out there that will break when this module is no longer available.

This is the kind of move that makes PHP expensive for companies to use, and the PHP core developers really need to think about this.

No comments:

Post a Comment