From: Ilia Alshanetsky Date: Tue, 4 Dec 2007 13:05:03 +0000 (+0000) Subject: MFB: Fixed bug #43493 (pdo_pgsql does not send username on connect when X-Git-Tag: php-5.2.6RC1~265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb9384cb8ab1865a4a6e803af7df6cba599882d7;p=php MFB: Fixed bug #43493 (pdo_pgsql does not send username on connect when password is not available) --- diff --git a/NEWS b/NEWS index af67cbd75d..15b37ad674 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2008, PHP 5.2.6 - Fixed weired behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson) +- Fixed bug #43493 (pdo_pgsql does not send username on connect when password + is not available). (Ilia) - Fixed bug #43482 (array_pad() does not warn on very small pad numbers). (Ilia) - Fixed bug #43457 (Prepared statement with incorrect parms doesn't throw diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index c134a2eb1d..922daccc75 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -692,14 +692,14 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ } /* support both full connection string & connection string + login and/or password */ - if (!dbh->username || !dbh->password) { - spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout); - } else if (dbh->username && dbh->password) { + if (dbh->username && dbh->password) { spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%ld", dbh->data_source, dbh->username, dbh->password, connect_timeout); } else if (dbh->username) { spprintf(&conn_str, 0, "%s user=%s connect_timeout=%ld", dbh->data_source, dbh->username, connect_timeout); - } else { + } else if (dbh->password) { spprintf(&conn_str, 0, "%s password=%s connect_timeout=%ld", dbh->data_source, dbh->password, connect_timeout); + } else { + spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout); } H->server = PQconnectdb(conn_str);