From 1a05e62dac195b5ab71ddfeec085d2d3c7f636ec Mon Sep 17 00:00:00 2001 From: hawk__ Date: Wed, 3 Aug 2011 21:30:21 +0000 Subject: [PATCH] The required handling code wasn't loaded in some cases when a plugin created his own tables in the database git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@418968 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- pg4wp/driver_pgsql.php | 10 +++++----- pg4wp/driver_pgsql_install.php | 2 +- readme.txt | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 8f4eff2..e448b15 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -16,10 +16,6 @@ if ( !extension_loaded('pgsql') ) wp_die( 'Your PHP installation appears to be missing the PostgreSQL extension which is required by WordPress with PG4WP.' ); - // Load up upgrade and install functions as required - if( defined( 'WP_INSTALLING') && WP_INSTALLING) - require_once( PG4WP_ROOT.'/driver_pgsql_install.php'); - // Initializing some variables $GLOBALS['pg4wp_result'] = 0; $GLOBALS['pg4wp_numrows'] = '10'; @@ -283,8 +279,12 @@ $logto = 'OPTIMIZE'; $sql = str_replace( 'OPTIMIZE TABLE', 'VACUUM', $sql); } - elseif( defined('WP_INSTALLING') && WP_INSTALLING) + // Load up upgrade and install functions as required + elseif( 0 === strpos( $sql, 'CREATE') || (defined('WP_INSTALLING') && WP_INSTALLING)) + { + require_once( PG4WP_ROOT.'/driver_pgsql_install.php'); $sql = pg4wp_installing( $sql, $logto); + } // WP 2.9.1 uses a comparison where text data is not quoted $pattern = '/AND meta_value = (-?\d+)/'; diff --git a/pg4wp/driver_pgsql_install.php b/pg4wp/driver_pgsql_install.php index 2c02eae..75b2fe2 100644 --- a/pg4wp/driver_pgsql_install.php +++ b/pg4wp/driver_pgsql_install.php @@ -148,7 +148,7 @@ WHERE pg_class.relname='$table_name' AND pg_attribute.attnum>=1 AND NOT pg_attri elseif( 0 === strpos($sql, 'CREATE TABLE')) { $logto = 'CREATE'; - $pattern = '/CREATE TABLE (\w+)/'; + $pattern = '/CREATE TABLE [`]?(\w+)[`]?/'; preg_match($pattern, $sql, $matches); $table = $matches[1]; diff --git a/readme.txt b/readme.txt index b47fcce..d7db692 100644 --- a/readme.txt +++ b/readme.txt @@ -51,6 +51,7 @@ There is no screenshot for this plugin == Changelog == = 1.2.0b1 = +* Somewhat improved Wordpress plugins compatibility * 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