mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-30 01:37:13 +02:00
Split 'db.php' so it is now just some kind of a 'bootloader'
The 'pg4wp' directory should be put in 'wp-content' instead of 'wp-content/plugins' (which is still supported) git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@418484 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
36
pg4wp/core.php
Normal file
36
pg4wp/core.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package PostgreSQL_For_Wordpress
|
||||||
|
* @version $Id$
|
||||||
|
* @author Hawk__, www.hawkix.net
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file does all the initialisation tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// Load the driver defined in 'db.php'
|
||||||
|
require_once( PG4WP_ROOT.'/driver_'.DB_DRIVER.'.php');
|
||||||
|
|
||||||
|
// This loads up the wpdb class applying appropriate changes to it
|
||||||
|
$replaces = array(
|
||||||
|
'define( ' => '// define( ',
|
||||||
|
'class wpdb' => 'class wpdb2',
|
||||||
|
'new wpdb' => 'new wpdb2',
|
||||||
|
'mysql_' => 'wpsql_',
|
||||||
|
'<?php' => '',
|
||||||
|
'?>' => '',
|
||||||
|
);
|
||||||
|
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 );
|
46
pg4wp/db.php
46
pg4wp/db.php
@ -3,52 +3,34 @@
|
|||||||
Plugin Name: PostgreSQL for WordPress (PG4WP)
|
Plugin Name: PostgreSQL for WordPress (PG4WP)
|
||||||
Plugin URI: http://www.hawkix.net
|
Plugin URI: http://www.hawkix.net
|
||||||
Description: PG4WP is a special 'plugin' enabling WordPress to use a PostgreSQL database.
|
Description: PG4WP is a special 'plugin' enabling WordPress to use a PostgreSQL database.
|
||||||
Version: 1.1.0
|
Version: 1.2.0b1
|
||||||
Author: Hawk__
|
Author: Hawk__
|
||||||
Author URI: http://www.hawkix.net
|
Author URI: http://www.hawkix.net
|
||||||
License: GPLv2 or newer.
|
License: GPLv2 or newer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if( !defined('PG4WP_ROOT'))
|
if( !defined('PG4WP_ROOT'))
|
||||||
{
|
{
|
||||||
|
|
||||||
// You can choose the driver to load here
|
// You can choose the driver to load here
|
||||||
define('DB_DRIVER', 'pgsql'); // 'pgsql' or 'mysql' are supported for now
|
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
|
// Set this to 'true' and check that `pg4wp` is writable if you want debug logs to be written
|
||||||
define( 'PG4WP_DEBUG', false);
|
define( 'PG4WP_DEBUG', false);
|
||||||
// If you just want to log queries that generate errors, leave PG4WP_DEBUG to "false"
|
// If you just want to log queries that generate errors, leave PG4WP_DEBUG to "false"
|
||||||
// and set this to true
|
// and set this to true
|
||||||
define( 'PG4WP_LOG_ERRORS', true);
|
define( 'PG4WP_LOG_ERRORS', true);
|
||||||
|
|
||||||
// Logs are put in the pg4wp directory
|
// If you want to allow insecure configuration (from the author point of view) to work with PG4WP,
|
||||||
define( 'PG4WP_LOG', PG4WP_ROOT.'/logs/');
|
// change this to true
|
||||||
// Check if the logs directory is needed and exists or create it if possible
|
define( 'PG4WP_INSECURE', false);
|
||||||
if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) &&
|
|
||||||
!file_exists( PG4WP_LOG) &&
|
|
||||||
is_writable(dirname( PG4WP_LOG)))
|
|
||||||
mkdir( PG4WP_LOG);
|
|
||||||
|
|
||||||
// Load the driver defined above
|
// This defines the directory where PG4WP files are loaded from
|
||||||
require_once( PG4WP_ROOT.'/driver_'.DB_DRIVER.'.php');
|
// 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 !
|
// Here happens all the magic
|
||||||
$replaces = array(
|
require_once( PG4WP_ROOT.'/core.php');
|
||||||
'define( ' => '// define( ',
|
} // Protection against multiple loading
|
||||||
'class wpdb' => 'class wpdb2',
|
|
||||||
'new wpdb' => 'new wpdb2',
|
|
||||||
'mysql_' => 'wpsql_',
|
|
||||||
'<?php' => '',
|
|
||||||
'?>' => '',
|
|
||||||
);
|
|
||||||
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
|
|
||||||
|
10
readme.txt
10
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 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.
|
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`
|
1. Copy the `dp.php` from the `pg4wp` directory to `wp-content`
|
||||||
|
|
||||||
@ -50,6 +50,9 @@ There is no screenshot for this plugin
|
|||||||
|
|
||||||
== Changelog ==
|
== 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
|
* Improved Akismet compatibility
|
||||||
* Upgrading works with minor errors (PostgreSQL complains about already existing relations)
|
* 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
|
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 ==
|
== 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 =
|
= 1.0 =
|
||||||
Initial stable release, you should upgrade to this version if you have installed any older release
|
Initial stable release, you should upgrade to this version if you have installed any older release
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user