]> granicus.if.org Git - php/commitdiff
Replacing MYSQL_TEST_COMPRESS env var with more generic MYSQL_TEST_CONNECT_FLAGS...
authorUlf Wendel <uw@php.net>
Fri, 25 Sep 2009 10:54:16 +0000 (10:54 +0000)
committerUlf Wendel <uw@php.net>
Fri, 25 Sep 2009 10:54:16 +0000 (10:54 +0000)
ext/mysqli/tests/connect.inc
ext/mysqli/tests/mysqli_connect_errno.phpt
ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
ext/mysqli/tests/mysqli_max_links.phpt

index f7c63ee4c0ea1b620898c71bbf1e82c3da75fc2c..ad2428647c85473c5e66534ed1a08317198bde0d 100644 (file)
@@ -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')) {
        /**
        * 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);
                }
        /**
        * 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);
                        }
index 068f10d7aaad98c56c1c020f65607d542a148f50..b48a75ef8c0bf900fce6752acf1c94d39abf771e 100644 (file)
@@ -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);
index af36ad8846738ac2c7192ee7378da8a2bb47b0e2..1c2defc8b06c827e66ba119438ffdf62150e71e9 100644 (file)
@@ -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)
index e1c9d4861ef7f85e578eff0e8f270c110b5fd719..7f49419401d32327d4372422352e4f7cc7f9fabe 100644 (file)
@@ -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