MiniBB Database Calls

This script has been around for a long time (much of it is still coded in a way more suited to Netscape 4 and earlier browsers rather than more modern browsers). This means that it was written to use the mysql_ interface to mySQL as the two more modern alternatives did not exist at the time it was written. The newer mysqli_ and PDO interfaces were introduced in PHP 5.0 and as these provide both greater flexibility and greater security than the older mysql_ interface the old interface was deprecated as of PHP 5.5. While at the time of writing no date has yet been given for when the next version of PHP is to be released (which will no longer support mysql_) the advantages of the newer interfaces and the ease with which you can convert to them means that there is no reason whatever for holding off on converting.

Unfortunately the original authors of miniBB have a policy of continuing to use obsolete code as long as it is still supported. This means that the script still uses HTML 3.2 (obsolete since 1997) and the mysql_ interface. Fortunately they released the script under a licence that allows others to upgrade their script and make the upgraded version available to others provided that the same rights are passed along.

After the original authors turned down my suggestion of updating their script to get rid of the obsolete mySQL interface and replace it with a more modern one I decided to take a look at making the changes myself. The script put all of the database calls in the one file and so there was only that one file that needed to be rewritten and substituted into the script to remove the obsolete PHP calls (if only getting rid of the obsolete HTML was as easy). It took me about 15 minutes to update the code to use mysqli_ instead of mysql_ calls and to test that the script works with the new code. In making these updates I simply substituted the equivalent calls - actually updating the calls to implement some of the better security features that the newer interface provides will have to wait for another time (or if you are a PHP programmer you are of course welcome under the original software licence to take my version and apply those changes yourself and them make that available for everyone to substitute into the script).

To update your copy of miniBB to get rid of the obsolete mysql_ interface and replace it with the mysqli_ one simply download the updated file and upload it to your site in place of the current one. Note that this conversion is based on the latest miniBB version available at the time I did the update and so if you have a more recent version of miniBB that has changes this file then you will need to reapply the changes made in the one upgrade to the file from the other upgrade. Given how close mysql_ is to being completely removed from PHP I don't really expect that there will be any updates to this file in future miniBB versions though unless they convert the interface first (possibly by copying my file into the next version of the script - as would be allowed by the licence provided that they keep the comment indicating that I did the mysqli_ conversion).

Disclaimer: As I did not write the original script I am not as familiar with the code as the original authors and so the testing that I have done may have missed something. If you find a spot in the code where the database calls fail please let me know.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow