From 534de602842089ae2579cce05050b3ce84db0202 Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Fri, 5 Aug 2011 13:39:30 +0000 Subject: [PATCH] Fix for bug #55283 SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections --- ext/mysqli/mysqli_nonapi.c | 10 ++++--- ext/mysqli/tests/bug55283.phpt | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 ext/mysqli/tests/bug55283.phpt diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 8dbaed2bff..2844c4df1b 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -141,10 +141,12 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne hostname = MyG(default_host); } - if (mysql->mysql && mysqli_resource && (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED || (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)))) { - /* already connected, we should close the connection */ - php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC); - } + if (mysql->mysql && mysqli_resource && + (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED)) + { + /* already connected, we should close the connection */ + php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC); + } if (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)) { hostname += 2; diff --git a/ext/mysqli/tests/bug55283.phpt b/ext/mysqli/tests/bug55283.phpt new file mode 100644 index 0000000000..0611c773cf --- /dev/null +++ b/ext/mysqli/tests/bug55283.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #55283 (SSL options set by mysqli_ssl_set ignored for MySQLi persistent connections) +--SKIPIF-- +query("SHOW STATUS LIKE 'Ssl_cipher'"); + $row = $res->fetch_row(); + if ($row[1] === "") { + die('skip Server started without SSL support'); + } +} +?> +--FILE-- +query("SHOW STATUS LIKE 'Ssl_cipher'"); + var_dump($r->fetch_row()); + } + + /* non-persistent connection */ + $link2 = mysqli_init(); + mysqli_ssl_set($link2, null, null, null, null, "RC4-MD5"); + if (my_mysqli_real_connect($link2, $host, $user, $passwd, $db, $port, null, $flags)) { + $r2 = $link2->query("SHOW STATUS LIKE 'Ssl_cipher'"); + var_dump($r2->fetch_row()); + } + + echo "done\n"; +?> +--EXPECTF-- +array(2) { + [0]=> + string(10) "Ssl_cipher" + [1]=> + string(7) "RC4-MD5" +} +array(2) { + [0]=> + string(10) "Ssl_cipher" + [1]=> + string(7) "RC4-MD5" +} +done \ No newline at end of file -- 2.40.0