diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index f7c63ee4c0e..ad2428647c8 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -16,7 +16,7 @@ $engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM"; $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; - $test_compress = getenv("MYSQL_TEST_COMPRESS") ? (boolean)getenv("MYSQL_TEST_COMPRESS") : false; + $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? @@ -51,6 +51,7 @@ /* unknown */ $MYSQLND_VERSION = -1; } + } if (!function_exists('sys_get_temp_dir')) { @@ -76,17 +77,17 @@ /** * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible * - * @param compress mixed: -1 => use global default, false -> no compression, true -> compression + * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)? */ - function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $compress = -1) { - global $test_compress; + function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { + global $connect_flags; - if (-1 == $compress) - $compress = $test_compress; + $flags = ($enable_env_flags) ? $connect_flags : false; - if ($compress) { + if ($flags !== false) { $link = mysqli_init(); - mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) + $link = false; } else { $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); } @@ -97,27 +98,26 @@ /** * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible * - * @param compress mixed: -1 => use global default, false -> no compression, true -> compression + * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS) */ - function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $compress = -1) { - global $test_compress; + function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) { + global $connect_flags; - if (-1 == $compress) - $compress = $test_compress; + if ($enable_env_flags) + $flags & $connect_flags; - return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags & MYSQLI_CLIENT_COMPRESS); + return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags); } class my_mysqli extends mysqli { - public function __construct($host, $user, $passwd, $db, $port, $socket, $compress = -1) { - global $test_compress; + public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { + global $connect_flags; - if (-1 == $compress) - $compress = $test_compress; + $flags = ($enable_env_flags) ? $connect_flags : false; - if ($compress) { + if ($flags !== false) { parent::init(); - $this->real_connect($host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS); + $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags); } else { parent::__construct($host, $user, $passwd, $db, $port, $socket); } diff --git a/ext/mysqli/tests/mysqli_connect_errno.phpt b/ext/mysqli/tests/mysqli_connect_errno.phpt index 068f10d7aaa..b48a75ef8c0 100644 --- a/ext/mysqli/tests/mysqli_connect_errno.phpt +++ b/ext/mysqli/tests/mysqli_connect_errno.phpt @@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc'); $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); if (false !== $link) printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n", - $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link); + $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true)); if (0 === ($tmp = mysqli_connect_errno())) printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp); diff --git a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt index af36ad88467..1c2defc8b06 100644 --- a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt @@ -28,12 +28,12 @@ new mysqli() var_dump(mysqli_connect_errno()); print "3) bail\n"; - if (false !== ($link = my_mysqli_connect($myhost))) { + if (false !== ($link = mysqli_connect($myhost))) { printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } print "4) be quiet\n"; - if (false !== ($link = @my_mysqli_connect($myhost))) { + if (false !== ($link = @mysqli_connect($myhost))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } var_dump(mysqli_connect_error()); @@ -50,7 +50,7 @@ Warning: mysqli::mysqli(): (HY000/200%d): %s int(200%d) 3) bail -Warning: my_mysqli_connect(): (HY000/200%d): %s +Warning: mysqli_connect(): (HY000/200%d): %s 4) be quiet %s(%d) "%s" int(200%d) diff --git a/ext/mysqli/tests/mysqli_max_links.phpt b/ext/mysqli/tests/mysqli_max_links.phpt index e1c9d4861ef..7f49419401d 100644 --- a/ext/mysqli/tests/mysqli_max_links.phpt +++ b/ext/mysqli/tests/mysqli_max_links.phpt @@ -44,15 +44,15 @@ mysqli.max_links=1 bool(true) int(1) -Warning: mysqli_connect(): Too many open links (1) in %s on line %d +Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d -Warning: mysqli_connect(): Too many open links (1) in %s on line %d +Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d -Warning: mysqli_connect(): Too many open links (1) in %s on line %d +Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d -Warning: mysqli_connect(): Too many open links (1) in %s on line %d +Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d -Warning: mysqli_connect(): Too many open links (1) in %s on line %d +Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d