1--TEST-- 2mysqli_kill() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 require('table.inc'); 14 15 try { 16 mysqli_kill($link, 0); 17 } catch (\ValueError $e) { 18 echo $e->getMessage() . \PHP_EOL; 19 } 20 21 if (!$thread_id = mysqli_thread_id($link)) 22 printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 23 24 $tmp = mysqli_kill($link, $thread_id); 25 if (!is_bool($tmp)) 26 printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); 27 28 if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) 29 pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); 30 31 var_dump($error = mysqli_error($link)); 32 if (!is_string($error) || ('' === $error)) 33 printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); 34 var_dump($res); 35 var_dump($link); 36 if ($IS_MYSQLND) { 37 if ($link->info != 'Records: 6 Duplicates: 0 Warnings: 0') { 38 printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); 39 } 40 } else { 41 if ($link->info != NULL) { 42 printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n"); 43 } 44 } 45 46 mysqli_close($link); 47 48 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 49 printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 50 51 try { 52 mysqli_kill($link, -1); 53 } catch (\ValueError $e) { 54 echo $e->getMessage() . \PHP_EOL; 55 } 56 if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || 57 (!$tmp = mysqli_fetch_assoc($res))) { 58 printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 59 } 60 var_dump($tmp); 61 mysqli_free_result($res); 62 mysqli_close($link); 63 64 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 65 printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 66 67 mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); 68 try { 69 mysqli_kill($link, -1); 70 } catch (\ValueError $e) { 71 echo $e->getMessage() . \PHP_EOL; 72 } 73 74 mysqli_close($link); 75 76 print "done!"; 77?> 78--CLEAN-- 79<?php 80 require_once("clean_table.inc"); 81?> 82--EXPECTF-- 83mysqli_kill(): Argument #2 ($process_id) must be greater than 0 84string(%d) "%s" 85bool(false) 86object(mysqli)#%d (%d) { 87 ["affected_rows"]=> 88 int(-1) 89 ["client_info"]=> 90 string(%d) "%s" 91 ["client_version"]=> 92 int(%d) 93 ["connect_errno"]=> 94 int(0) 95 ["connect_error"]=> 96 NULL 97 ["errno"]=> 98 int(%d) 99 ["error"]=> 100 string(%d) "%s" 101 ["error_list"]=> 102 array(1) { 103 [0]=> 104 array(3) { 105 ["errno"]=> 106 int(%d) 107 ["sqlstate"]=> 108 string(5) "%s" 109 ["error"]=> 110 string(%d) "%s" 111 } 112 } 113 ["field_count"]=> 114 int(0) 115 ["host_info"]=> 116 string(%d) "%s" 117 ["info"]=> 118 %s 119 ["insert_id"]=> 120 int(0) 121 ["server_info"]=> 122 string(%d) "%s" 123 ["server_version"]=> 124 int(%d) 125 ["sqlstate"]=> 126 string(5) "HY000" 127 ["protocol_version"]=> 128 int(10) 129 ["thread_id"]=> 130 int(%d) 131 ["warning_count"]=> 132 int(0) 133} 134mysqli_kill(): Argument #2 ($process_id) must be greater than 0 135array(1) { 136 ["id"]=> 137 string(1) "1" 138} 139mysqli_kill(): Argument #2 ($process_id) must be greater than 0 140done! 141