summaryrefslogtreecommitdiff
path: root/includes/database/pgsql
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-08-16 21:01:23 +0000
committerDries Buytaert <dries@buytaert.net>2010-08-16 21:01:23 +0000
commit03630c12e556a5f715b735428d4951f7bde31dc4 (patch)
treeae281d7e8fdc2606ffaf91356adfed98e3473ed9 /includes/database/pgsql
parentb82715c333aae239ea4cf62a0750d1fd45504cee (diff)
downloadbrdo-03630c12e556a5f715b735428d4951f7bde31dc4.tar.gz
brdo-03630c12e556a5f715b735428d4951f7bde31dc4.tar.bz2
- Patch #862078 by gustavb, Damien Tournoud: PDO coerceing empty strings to NULL when target is a Postgres bytea.
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r--includes/database/pgsql/install.inc31
1 files changed, 10 insertions, 21 deletions
diff --git a/includes/database/pgsql/install.inc b/includes/database/pgsql/install.inc
index bfd69d414..82ba57ca8 100644
--- a/includes/database/pgsql/install.inc
+++ b/includes/database/pgsql/install.inc
@@ -57,29 +57,18 @@ class DatabaseTasks_pgsql extends DatabaseTasks {
/**
* Check PHP version.
*
- * There is a bug in PHP versions < 5.2.11 and < 5.3.1 that prevents
- * PostgreSQL from inserting integer values into numeric columns that exceed
- * the PHP_INT_MAX value (value varies dependant on 32 or 64 bit CPU).
+ * There are two bugs in PDO_pgsql affecting Drupal:
+ *
+ * - in versions < 5.2.7, PDO_pgsql refuses to insert an empty string into
+ * a NOT NULL BLOB column. See: http://bugs.php.net/bug.php?id=46249
+ * - in versions < 5.2.11 and < 5.3.1 that prevents inserting integer values
+ * into numeric columns that exceed the PHP_INT_MAX value.
+ * See: http://bugs.php.net/bug.php?id=48924
*/
function checkPHPVersion() {
- try {
- $txn = db_transaction();
- db_query("CREATE TABLE test_php_version ( test_int INT NOT NULL )");
- // See http://bugs.php.net/bug.php?id=48924 as to why this query may
- // fail. The error will throw an Exception so there is no need to test to
- // see if the row inserted or not.
- db_query("INSERT INTO test_php_version ( test_int ) VALUES (:big_int)", array(':big_int' => PHP_INT_MAX + 1));
- db_query("DROP TABLE test_php_version");
- $this->pass(st('PHP is at the correct version to run on PostgreSQL.'));
- }
- catch (Exception $e) {
- // Failing is not fatal but the user should still be warned of the
- // limitations of running PostgreSQL on the current version of PHP.
- $text = 'The version of PHP you are using has known issues with PostgreSQL. You can see more at ';
- $text .= l('http://drupal.org/node/515310', 'http://drupal.org/node/515310') . '. ';
- $text .= 'We suggest you upgrade PHP to 5.2.11, 5.3.1 or greater. Failing to do so may result in serious data corruption later.';
- drupal_set_message(st($text), 'warning');
- }
+ if (!version_compare(PHP_VERSION, '5.2.11', '>=') || (version_compare(PHP_VERSION, '5.3.0', '>=') && !version_compare(PHP_VERSION, '5.3.1', '>='))) {
+ $this->fail(st('The version of PHP you are using has known issues with PostgreSQL. You need to upgrade PHP to 5.2.11, 5.3.1 or greater.'));
+ };
}
/**