So over here at BeefyApps are using PostgreSQL instead of MySQL for our WordPress backend. There is this discussion in the WordPress codex which talks about why they do not natively support PostgreSQL out of the box.

However, we have decided that PostgreSQL is the way forward for us so we needed to find a work around. Luckily for us there is a plugin, PostgreSQL for WordPress, which will allow us to do this.

So I followed the steps that were laid out in the Readme.txt that is bundled with the package and I eventually came to run the installation (after the configuration) and I was presented with a blank white screen. Not so lucky after all…

I went through the logs and found:

PHP Fatal error:  Cannot redeclare class wpdb

Which was originating in the class wp-db.php in the wp-includes directory. This was being invoked from the wp-admin/setup-config.php file.

After some searching on the internet I came across some other posts talking about modifying the wp-functions.php file and some others which didn’t really seem appropriate because they would be overwritten with an upgrade. I did find that in the wp-admin/install.php file, there was a reference to wp-db.php as part of the installer. I commented this section out and the installer ran successfully.

I think this problem occurs because before the db.php file can run and eval the class definition inside the wp-db.php file, after it makes it’s replacements for the file, the install.php file has already loaded and processed that class into memory. When we try to redefine the class it throws an error. Anyway it seems to work now.