Skip to content

Deprecate mysqli_kill #11926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ public function init() {}
* @tentative-return-type
* @alias mysqli_kill
*/
#[\Deprecated(since: '8.4', message: 'use KILL CONNECTION/QUERY SQL statement instead')]
public function kill(int $process_id): bool {}

/**
Expand Down Expand Up @@ -1505,6 +1506,7 @@ function mysqli_info(mysqli $mysql): ?string {}
/** @refcount 1 */
function mysqli_insert_id(mysqli $mysql): int|string {}

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

function mysqli_more_results(mysqli $mysql): bool {}
Expand Down
30 changes: 27 additions & 3 deletions ext/mysqli/mysqli_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion ext/mysqli/tests/071.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ require_once 'skipifconnectfailure.inc';
$mysql->close();
print "done!";
?>
--EXPECT--
--EXPECTF--
bool(true)

Deprecated: Method mysqli::kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
bool(false)
bool(true)

Deprecated: Method mysqli::kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
bool(false)
done!
8 changes: 8 additions & 0 deletions ext/mysqli/tests/mysqli_kill.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ require_once 'skipifconnectfailure.inc';
require_once 'clean_table.inc';
?>
--EXPECTF--

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
mysqli_kill(): Argument #2 ($process_id) must be greater than 0

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
string(%d) "%s"
bool(false)
object(mysqli)#%d (%d) {
Expand Down Expand Up @@ -123,10 +127,14 @@ object(mysqli)#%d (%d) {
["warning_count"]=>
int(0)
}

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
array(1) {
["id"]=>
string(1) "1"
}

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
done!
6 changes: 3 additions & 3 deletions ext/mysqli/tests/mysqli_poll_kill.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require_once 'skipifconnectfailure.inc';
// Sleep 0.1s - the asynchronous query should have been processed after the wait period
usleep(100000);
$thread_id = mysqli_thread_id($link);
mysqli_kill(get_connection(), $thread_id);
get_connection()->query('KILL '.$thread_id);

$links = array($link);
$errors = array($link);
Expand Down Expand Up @@ -82,7 +82,7 @@ require_once 'skipifconnectfailure.inc';

usleep(100000);
$thread_id = mysqli_thread_id($link);
mysqli_kill(get_connection(), $thread_id);
get_connection()->query('KILL '.$thread_id);

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

$link = get_connection();
$thread_id = mysqli_thread_id($link);
mysqli_kill(get_connection(), $thread_id);
get_connection()->query('KILL '.$thread_id);
// Sleep 0.1s to ensure the KILL gets recognized
usleep(100000);
if (false !== ($tmp = mysqli_query($link, "SELECT 1 AS 'processed before killed'", MYSQLI_ASYNC | MYSQLI_USE_RESULT)))
Expand Down
10 changes: 10 additions & 0 deletions ext/mysqli/tests/mysqli_report.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ require_once 'clean_table.inc';
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

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

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
mysqli_kill(): Argument #2 ($process_id) must be greater than 0

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
Expand All @@ -333,9 +335,17 @@ Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; ch
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

Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
mysqli_kill(): Argument #2 ($process_id) must be greater than 0

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

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
[013] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
[016] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
done!
4 changes: 2 additions & 2 deletions ext/mysqli/tests/mysqli_stmt_close.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_execute($stmt))
printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));

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

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

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

if (true !== ($tmp = mysqli_stmt_close($stmt)))
printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_stmt_errno.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require_once 'skipifconnectfailure.inc';
if (0 != ($tmp = mysqli_stmt_errno($stmt)))
printf("[008] Expecting zero, got %s/%s\n", gettype($tmp), $tmp);

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

if (true === ($tmp = mysqli_stmt_execute($stmt)))
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_stmt_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require_once 'skipifconnectfailure.inc';
if ('' !== ($tmp = mysqli_stmt_error($stmt)))
printf("[008] Expecting empty string, got %s/%s\n", gettype($tmp), $tmp);

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

if (true === ($tmp = mysqli_stmt_execute($stmt)))
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_stmt_execute.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ require_once 'skipifconnectfailure.inc';
var_dump(mysqli_stmt_execute($stmt));
var_dump(mysqli_stmt_fetch($stmt));

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

if (false !== ($tmp = mysqli_stmt_execute($stmt)))
printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_stmt_fetch.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require_once 'skipifconnectfailure.inc';
printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n",
gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));

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

if (true !== ($tmp = mysqli_stmt_fetch($stmt)))
Expand Down
4 changes: 3 additions & 1 deletion ext/mysqli/tests/mysqli_stmt_get_result.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ require_once 'skipifconnectfailure.inc';
}
mysqli_free_result($result);

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

if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
Expand Down
7 changes: 5 additions & 2 deletions ext/mysqli/tests/mysqli_thread_id.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ require_once 'skipifconnectfailure.inc';
gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));

// should work if the thread id is correct
mysqli_kill($link, mysqli_thread_id($link));

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

mysqli_close($link);

try {
Expand Down
Loading