BUGFIX Fixed border case where pg_version() could return false and break functionality in PostgreSQLDatabaseConfigurationHelper::requireDatabaseVersion()

This commit is contained in:
Sean Harvey 2010-05-15 04:06:15 +00:00
parent 5f17db6599
commit 2c38c37bb2

View File

@ -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()");