mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-09-28 05:40:56 +02:00
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 <kevin@kevinlocke.name>
This commit is contained in:
@@ -270,6 +270,10 @@
|
||||
// MySQL 'IF' conversion - Note : NULLIF doesn't need to be corrected
|
||||
$pattern = '/ (?<!NULL)IF[ ]*\(([^,]+),([^,]+),([^\)]+)\)/';
|
||||
$sql = preg_replace( $pattern, ' CASE WHEN $1 THEN $2 ELSE $3 END', $sql);
|
||||
|
||||
// Act like MySQL default configuration, where sql_mode is ""
|
||||
$pattern = '/@@SESSION.sql_mode/';
|
||||
$sql = preg_replace( $pattern, "''", $sql);
|
||||
|
||||
$sql = str_replace('GROUP BY '.$wpdb->prefix.'posts.ID', '' , $sql);
|
||||
$sql = str_replace("!= ''", '<> 0', $sql);
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user