From c89f56060561c9ce9429edbf0c650b0c6b592edd Mon Sep 17 00:00:00 2001 From: hawk__ Date: Sun, 11 Sep 2011 00:00:04 +0000 Subject: [PATCH] Correct SQL_CALC_FOUND_ROWS handling as it was broken by the latest code reorganisation git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@436152 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- pg4wp/driver_pgsql.php | 14 ++++---------- readme.txt | 5 ++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 28dff49..809f0d2 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -129,12 +129,6 @@ if( false === strpos($err, 'relation "'.$wpdb->options.'"')) error_log("Error running :\n$initial\n---- converted to ----\n$sql\n----\n$err\n---------------------\n", 3, PG4WP_LOG.'pg4wp_errors.log'); - if( $catchnumrows && $GLOBALS['pg4wp_result'] !== false) - { - $GLOBALS['pg4wp_numrows_query'] = $sql; - if( PG4WP_DEBUG) - error_log( "Number of rows required for :\n$sql\n---------------------\n", 3, PG4WP_LOG.'pg4wp_NUMROWS.log'); - } return $GLOBALS['pg4wp_result']; } @@ -166,8 +160,6 @@ global $wpdb; $logto = 'queries'; - // This is used to catch the number of rows returned by the last "SELECT" REQUEST - $catchnumrows = false; // The end of the query may be protected against changes $end = ''; @@ -180,12 +172,14 @@ // SQL_CALC_FOUND_ROWS doesn't exist in PostgreSQL but it's needed for correct paging if( false !== strpos($sql, 'SQL_CALC_FOUND_ROWS')) { - $catchnumrows = true; $sql = str_replace('SQL_CALC_FOUND_ROWS', '', $sql); + $GLOBALS['pg4wp_numrows_query'] = $sql; + if( PG4WP_DEBUG) + error_log( "Number of rows required for :\n$sql\n---------------------\n", 3, PG4WP_LOG.'pg4wp_NUMROWS.log'); } elseif( false !== strpos($sql, 'FOUND_ROWS()')) { - // Here we need to convert the latest query into a COUNT query + // Here we convert the latest query into a COUNT query $sql = $GLOBALS['pg4wp_numrows_query']; // Remove any LIMIT ... clause (this is the blocking part) $pattern = '/\s+LIMIT.+/'; diff --git a/readme.txt b/readme.txt index 5183c71..1c88f5d 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: database, postgresql, PostgreSQL, postgres, mysql Requires at least: 2.5.1 Tested up to: 3.2.1 -Stable tag: 1.2.1 +Stable tag: 1.2.2 PostgreSQL for WordPress is a special 'plugin' enabling WordPress to be used with a PostgreSQL database. @@ -43,6 +43,9 @@ There is no screenshot for this plugin == Changelog == += 1.2.2 = +* Corrected SQL_CALC_FOUND_ROWS handling, was broken by the latest code reorganisation + = 1.2.1 = * Corrected 'ON DUPLICATE KEY ...' handling (was not working at all) * Modified SQL_CALC_FOUND_ROWS handling for correct paging