From 2c38c37bb2afd44b924b1e243007794afe5d667b Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Sat, 15 May 2010 04:06:15 +0000 Subject: [PATCH] BUGFIX Fixed border case where pg_version() could return false and break functionality in PostgreSQLDatabaseConfigurationHelper::requireDatabaseVersion() --- code/PostgreSQLDatabaseConfigurationHelper.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/PostgreSQLDatabaseConfigurationHelper.php b/code/PostgreSQLDatabaseConfigurationHelper.php index d6f53bf..78ac68f 100644 --- a/code/PostgreSQLDatabaseConfigurationHelper.php +++ b/code/PostgreSQLDatabaseConfigurationHelper.php @@ -88,7 +88,6 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp public function requireDatabaseVersion($databaseConfig) { $success = false; $error = ''; - $version = 0; $username = $databaseConfig['username'] ? $databaseConfig['username'] : ''; $password = $databaseConfig['password'] ? $databaseConfig['password'] : ''; @@ -97,9 +96,8 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp $passwordPart = $password ? " password=$password" : ''; $connstring = "host=$server port=5432 dbname=postgres {$userPart}{$passwordPart}"; $conn = @pg_connect($connstring); - - $versionInfo = pg_version($conn); - $version = isset($versionInfo['server']) ? $versionInfo['server'] : null; + $info = @pg_version($conn); + $version = ($info && isset($info['server'])) ? $info['server'] : null; if(!$version) { // fallback to using the version() function $result = @pg_query($conn, "SELECT version()");