diff --git a/pg4wp/core.php b/pg4wp/core.php new file mode 100644 index 0000000..990c13f --- /dev/null +++ b/pg4wp/core.php @@ -0,0 +1,36 @@ + '// define( ', + 'class wpdb' => 'class wpdb2', + 'new wpdb' => 'new wpdb2', + 'mysql_' => 'wpsql_', + ' '', + '?>' => '', +); +eval( str_replace( array_keys($replaces), array_values($replaces), file_get_contents(ABSPATH.'/wp-includes/wp-db.php'))); + +// Create wpdb object if not already done +if (! isset($wpdb)) + $wpdb = new wpdb2( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); diff --git a/pg4wp/db.php b/pg4wp/db.php index 83ac6cc..bdc60bd 100644 --- a/pg4wp/db.php +++ b/pg4wp/db.php @@ -3,52 +3,34 @@ Plugin Name: PostgreSQL for WordPress (PG4WP) Plugin URI: http://www.hawkix.net Description: PG4WP is a special 'plugin' enabling WordPress to use a PostgreSQL database. -Version: 1.1.0 +Version: 1.2.0b1 Author: Hawk__ Author URI: http://www.hawkix.net License: GPLv2 or newer. */ + if( !defined('PG4WP_ROOT')) { - // You can choose the driver to load here define('DB_DRIVER', 'pgsql'); // 'pgsql' or 'mysql' are supported for now -// This defines the directory where PG4WP files are -define( 'PG4WP_ROOT', dirname( __FILE__).'/plugins/pg4wp'); - // Set this to 'true' and check that `pg4wp` is writable if you want debug logs to be written define( 'PG4WP_DEBUG', false); // If you just want to log queries that generate errors, leave PG4WP_DEBUG to "false" // and set this to true define( 'PG4WP_LOG_ERRORS', true); -// Logs are put in the pg4wp directory -define( 'PG4WP_LOG', PG4WP_ROOT.'/logs/'); -// Check if the logs directory is needed and exists or create it if possible -if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) && - !file_exists( PG4WP_LOG) && - is_writable(dirname( PG4WP_LOG))) - mkdir( PG4WP_LOG); +// If you want to allow insecure configuration (from the author point of view) to work with PG4WP, +// change this to true +define( 'PG4WP_INSECURE', false); -// Load the driver defined above -require_once( PG4WP_ROOT.'/driver_'.DB_DRIVER.'.php'); +// This defines the directory where PG4WP files are loaded from +// 2 places checked : wp-content and wp-content/plugins +if( file_exists( ABSPATH.'/wp-content/pg4wp')) + define( 'PG4WP_ROOT', ABSPATH.'/wp-content/pg4wp'); +else + define( 'PG4WP_ROOT', ABSPATH.'/wp-content/plugins/pg4wp'); -// This loads up the wpdb class applying the appropriate changes to it, DON'T TOUCH ! -$replaces = array( - 'define( ' => '// define( ', - 'class wpdb' => 'class wpdb2', - 'new wpdb' => 'new wpdb2', - 'mysql_' => 'wpsql_', - ' '', - '?>' => '', -); -eval( str_replace( array_keys($replaces), array_values($replaces), file_get_contents(ABSPATH.'/wp-includes/wp-db.php'))); -require_once( ABSPATH.'/wp-includes/wp-db.php'); - -if (! isset($wpdb)) { - // Create wpdb object if not already done - $wpdb = new wpdb2( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); -} - -} // Protection against multiple loading \ No newline at end of file +// Here happens all the magic +require_once( PG4WP_ROOT.'/core.php'); +} // Protection against multiple loading diff --git a/readme.txt b/readme.txt index 9db6f75..b47fcce 100644 --- a/readme.txt +++ b/readme.txt @@ -31,7 +31,7 @@ You have to install it before setting up your WordPress installation for things This section describes how to install the plugin and get it working. This is because the database needs to be up and running before any plugin can be loaded. -1. Unzip the files and put the `pg4wp` directory in your `/wp-content/plugins` directory. +1. Unzip the files and put the `pg4wp` directory in your `/wp-content` directory. 1. Copy the `dp.php` from the `pg4wp` directory to `wp-content` @@ -50,6 +50,9 @@ There is no screenshot for this plugin == Changelog == += 1.2.0b1 = +* Added 'PG4WP_INSECURE' parameter for future use +* Split 'db.php' to be just some kind of loader for PG4WP to ease upgrading * Improved Akismet compatibility * Upgrading works with minor errors (PostgreSQL complains about already existing relations) Tested successfully : 2.9.2 to 3.0.6 - 2.9.2 to 3.1.4 - 2.9.2 to 3.2.1 @@ -134,6 +137,11 @@ There is no screenshot for this plugin == Upgrade Notice == += 1.2.0 = +This version provides support for Wordpress up to 3.2.1 +Upgrading to this version requires you to replace your existing `dp.php` with the one from the `pg4wp` directory. +Note : since 1.2.0b1, it is recommended to put the `pg4wp` directory directly in `/wp-content` + = 1.0 = Initial stable release, you should upgrade to this version if you have installed any older release