From 83e5074461898046c33112249788883ea2547493 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Wed, 3 Jun 2015 01:12:12 -0600 Subject: [PATCH] Add support for sql_mode variable This appears as both "SELECT @@SESSION.sql_mode" checked from wp-db.php in Wordpress core during startup and as "SHOW VARIABLES LIKE 'sql_mode'" in several extensions (all-in-one-seo-pack, flash-album-gallery, and nextgen-gallery on my system). Support both by returning the empty string, which reports the default MySQL behavior (and avoids attempts to change the mode, since all current code expects this). Signed-off-by: Kevin Locke --- pg4wp/driver_pgsql.php | 4 ++++ pg4wp/driver_pgsql_install.php | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 637bbbd..c4dd3fb 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -270,6 +270,10 @@ // MySQL 'IF' conversion - Note : NULLIF doesn't need to be corrected $pattern = '/ (?prefix.'posts.ID', '' , $sql); $sql = str_replace("!= ''", '<> 0', $sql); diff --git a/pg4wp/driver_pgsql_install.php b/pg4wp/driver_pgsql_install.php index 3216aa2..7c0e437 100644 --- a/pg4wp/driver_pgsql_install.php +++ b/pg4wp/driver_pgsql_install.php @@ -41,8 +41,15 @@ // Emulate SHOW commands if( 0 === strpos( $sql, 'SHOW') || 0 === strpos( $sql, 'show')) { + // SHOW VARIABLES LIKE emulation for sql_mode + // Used by nextgen-gallery plugin + if( 0 === strpos( $sql, "SHOW VARIABLES LIKE 'sql_mode'")) + { + // Act like MySQL default configuration, where sql_mode is "" + $sql = 'SELECT \'sql_mode\' AS "Variable_name", \'\' AS "Value";'; + } // SHOW COLUMNS emulation - if( preg_match('/SHOW\s+(FULL\s+)?COLUMNS\s+(?:FROM\s+|IN\s+)`?(\w+)`?(?:\s+LIKE\s+(.+)|\s+WHERE\s+(.+))?/i', $sql, $matches)) + elseif( preg_match('/SHOW\s+(FULL\s+)?COLUMNS\s+(?:FROM\s+|IN\s+)`?(\w+)`?(?:\s+LIKE\s+(.+)|\s+WHERE\s+(.+))?/i', $sql, $matches)) { $logto = 'SHOWCOLUMN'; $full = $matches[1];