Skip to main content

WordPress and PHP 5.5

As some of you know the mysql extension is deprecated in PHP 5.5. Most likely it still works but when you want to use it now with WordPress it will fill up your logs. This will get fixed in WordPress 3.7 or maybe 3.8 depending on feature scope for 3.7. There is already a ticket on Trac that you can follow:

The focus on that ticket is switching to PDO but also have support for MySQLi and MySQL. There is still not a clear solution about how to solve the problem since switching will cause plugin breakage. If you read the ticket you read that 7.4% of all plugins on making  raw calls to mysql_*() functions. That is quite a lot and it will need a soft approach to tacle this issue.

Using it right now

Stop using MySQL is already possible with a custom wpdb class. The plugin WP DB Abstraction already does this for more then two years. It has’t been updated for a while and has some bugs. This is because it does more then MySQL abstraction since the goal was to allow MSSQL. A few days ago I created a small custom wpdb class what is a wrapper for MySQLi. It only get used when it is allowed. It works perfect and hides all notices when using PHP 5.5.

When writing this blog I was thinking why not moving ticket #21663 to a plugin. It’s something that is possible since you can control which class will be the $wpdb variable. So I just created a new GitHub repository for doing this. It works just as good as the MySQLi one. For this plugin I did add a settings page that shows what driver you  currently using and which one is installed. It also let you install it’s db.php to the content folder. This file is just a include to the one in the plugin folder. Reason for this is that the file can change and having it in the plugin folder make it easy updatable.

Download from

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.