Skip to content

Commit 7801f40

Browse files
Deprecate mysqli_kill (#11926)
1 parent 42497c1 commit 7801f40

13 files changed

+69
-16
lines changed

ext/mysqli/mysqli.stub.php

+2
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ public function init() {}
854854
* @tentative-return-type
855855
* @alias mysqli_kill
856856
*/
857+
#[\Deprecated(since: '8.4', message: 'use KILL CONNECTION/QUERY SQL statement instead')]
857858
public function kill(int $process_id): bool {}
858859

859860
/**
@@ -1505,6 +1506,7 @@ function mysqli_info(mysqli $mysql): ?string {}
15051506
/** @refcount 1 */
15061507
function mysqli_insert_id(mysqli $mysql): int|string {}
15071508

1509+
#[\Deprecated(since: '8.4', message: 'use KILL CONNECTION/QUERY SQL statement instead')]
15081510
function mysqli_kill(mysqli $mysql, int $process_id): bool {}
15091511

15101512
function mysqli_more_results(mysqli $mysql): bool {}

ext/mysqli/mysqli_arginfo.h

+27-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/mysqli/tests/071.phpt

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ require_once 'skipifconnectfailure.inc';
3838
$mysql->close();
3939
print "done!";
4040
?>
41-
--EXPECT--
41+
--EXPECTF--
4242
bool(true)
43+
44+
Deprecated: Method mysqli::kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
4345
bool(false)
4446
bool(true)
47+
48+
Deprecated: Method mysqli::kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
4549
bool(false)
4650
done!

ext/mysqli/tests/mysqli_kill.phpt

+8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ require_once 'skipifconnectfailure.inc';
7272
require_once 'clean_table.inc';
7373
?>
7474
--EXPECTF--
75+
76+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
7577
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
78+
79+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
7680
string(%d) "%s"
7781
bool(false)
7882
object(mysqli)#%d (%d) {
@@ -123,10 +127,14 @@ object(mysqli)#%d (%d) {
123127
["warning_count"]=>
124128
int(0)
125129
}
130+
131+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
126132
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
127133
array(1) {
128134
["id"]=>
129135
string(1) "1"
130136
}
137+
138+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
131139
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
132140
done!

ext/mysqli/tests/mysqli_poll_kill.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require_once 'skipifconnectfailure.inc';
2727
// Sleep 0.1s - the asynchronous query should have been processed after the wait period
2828
usleep(100000);
2929
$thread_id = mysqli_thread_id($link);
30-
mysqli_kill(get_connection(), $thread_id);
30+
get_connection()->query('KILL '.$thread_id);
3131

3232
$links = array($link);
3333
$errors = array($link);
@@ -82,7 +82,7 @@ require_once 'skipifconnectfailure.inc';
8282

8383
usleep(100000);
8484
$thread_id = mysqli_thread_id($link);
85-
mysqli_kill(get_connection(), $thread_id);
85+
get_connection()->query('KILL '.$thread_id);
8686

8787
// Yes, 1 - fetch OK packet of kill!
8888
$processed = 0;
@@ -140,7 +140,7 @@ require_once 'skipifconnectfailure.inc';
140140

141141
$link = get_connection();
142142
$thread_id = mysqli_thread_id($link);
143-
mysqli_kill(get_connection(), $thread_id);
143+
get_connection()->query('KILL '.$thread_id);
144144
// Sleep 0.1s to ensure the KILL gets recognized
145145
usleep(100000);
146146
if (false !== ($tmp = mysqli_query($link, "SELECT 1 AS 'processed before killed'", MYSQLI_ASYNC | MYSQLI_USE_RESULT)))

ext/mysqli/tests/mysqli_report.phpt

+10
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ require_once 'clean_table.inc';
314314
Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d
315315

316316
Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
317+
318+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
317319
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
318320

319321
Warning: mysqli_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
@@ -333,9 +335,17 @@ Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; ch
333335
Warning: mysqli_store_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
334336

335337
Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d
338+
339+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
336340
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
337341

338342
Warning: mysqli_stmt_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
343+
344+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
345+
346+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
347+
348+
Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
339349
[013] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
340350
[016] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
341351
done!

ext/mysqli/tests/mysqli_stmt_close.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require_once 'skipifconnectfailure.inc';
4646
if (!mysqli_stmt_execute($stmt))
4747
printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
4848

49-
mysqli_kill($link, mysqli_thread_id($link));
49+
$link->query('KILL '.mysqli_thread_id($link));
5050

5151
if (true !== ($tmp = mysqli_stmt_close($stmt)))
5252
printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
@@ -67,7 +67,7 @@ require_once 'skipifconnectfailure.inc';
6767
if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt))
6868
printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
6969

70-
mysqli_kill($link, mysqli_thread_id($link));
70+
$link->query('KILL '.mysqli_thread_id($link));
7171

7272
if (true !== ($tmp = mysqli_stmt_close($stmt)))
7373
printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);

ext/mysqli/tests/mysqli_stmt_errno.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require_once 'skipifconnectfailure.inc';
3131
if (0 != ($tmp = mysqli_stmt_errno($stmt)))
3232
printf("[008] Expecting zero, got %s/%s\n", gettype($tmp), $tmp);
3333

34-
mysqli_kill($link, mysqli_thread_id($link));
34+
$link->query('KILL '.mysqli_thread_id($link));
3535

3636
if (true === ($tmp = mysqli_stmt_execute($stmt)))
3737
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);

ext/mysqli/tests/mysqli_stmt_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require_once 'skipifconnectfailure.inc';
3131
if ('' !== ($tmp = mysqli_stmt_error($stmt)))
3232
printf("[008] Expecting empty string, got %s/%s\n", gettype($tmp), $tmp);
3333

34-
mysqli_kill($link, mysqli_thread_id($link));
34+
$link->query('KILL '.mysqli_thread_id($link));
3535

3636
if (true === ($tmp = mysqli_stmt_execute($stmt)))
3737
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);

ext/mysqli/tests/mysqli_stmt_execute.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ require_once 'skipifconnectfailure.inc';
108108
var_dump(mysqli_stmt_execute($stmt));
109109
var_dump(mysqli_stmt_fetch($stmt));
110110

111-
mysqli_kill($link, mysqli_thread_id($link));
111+
$link->query('KILL '.mysqli_thread_id($link));
112112

113113
if (false !== ($tmp = mysqli_stmt_execute($stmt)))
114114
printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);

ext/mysqli/tests/mysqli_stmt_fetch.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ require_once 'skipifconnectfailure.inc';
5757
printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n",
5858
gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
5959

60-
if (!mysqli_kill($link, mysqli_thread_id($link)))
60+
if (!$link->query('KILL '.mysqli_thread_id($link)))
6161
printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
6262

6363
if (true !== ($tmp = mysqli_stmt_fetch($stmt)))

ext/mysqli/tests/mysqli_stmt_get_result.phpt

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ require_once 'skipifconnectfailure.inc';
153153
}
154154
mysqli_free_result($result);
155155

156-
if (!mysqli_kill($link, mysqli_thread_id($link)))
156+
$link->real_query('KILL '.mysqli_thread_id($link));
157+
// We kill our own connection so we should get "Query execution was interrupted"
158+
if ($link->errno !== 1317)
157159
printf("[042] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
158160

159161
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))

ext/mysqli/tests/mysqli_thread_id.phpt

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ require_once 'skipifconnectfailure.inc';
2020
gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
2121

2222
// should work if the thread id is correct
23-
mysqli_kill($link, mysqli_thread_id($link));
24-
23+
$link->real_query('KILL '.mysqli_thread_id($link));
24+
// We kill our own connection so we should get "Query execution was interrupted"
25+
if ($link->errno !== 1317)
26+
printf("[042] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
27+
2528
mysqli_close($link);
2629

2730
try {

0 commit comments

Comments
 (0)