From 3742d7428ee114371b5765119a096346a9e37361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Fri, 19 Oct 2007 15:02:15 +0000 Subject: #125105 by Shiny and hwsong3i: fix installer pgsql connection parameters to work when password is not specified --- includes/install.pgsql.inc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'includes') diff --git a/includes/install.pgsql.inc b/includes/install.pgsql.inc index 935622e49..55473f27d 100644 --- a/includes/install.pgsql.inc +++ b/includes/install.pgsql.inc @@ -26,16 +26,24 @@ function drupal_test_pgsql($url, &$success) { } $url = parse_url($url); + $conn_string = ''; - // Decode url-encoded information in the db connection string. - $url['user'] = urldecode($url['user']); - $url['pass'] = urldecode($url['pass']); - $url['host'] = urldecode($url['host']); - $url['path'] = urldecode($url['path']); - - // Build pgsql connection string and allow for non-standard PostgreSQL port. - $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) .' password='. $url['pass'] .' host='. $url['host']; - $conn_string .= isset($url['port']) ? ' port='. $url['port'] : ''; + // Decode url-encoded information in the db connection string + if (isset($url['user'])) { + $conn_string .= ' user='. urldecode($url['user']); + } + if (isset($url['pass'])) { + $conn_string .= ' password='. urldecode($url['pass']); + } + if (isset($url['host'])) { + $conn_string .= ' host='. urldecode($url['host']); + } + if (isset($url['path'])) { + $conn_string .= ' dbname='. substr(urldecode($url['path']), 1); + } + if (isset($url['port'])) { + $conn_string .= ' port='. urldecode($url['port']); + } // Test connecting to the database. $connection = @pg_connect($conn_string); -- cgit v1.2.3