From 6f115d0aefabab00c469f05d0198b355537c1c6e Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 12 Aug 2023 13:49:24 +0100 Subject: [PATCH] Deprecate mysqli_ping --- ext/mysqli/mysqli.stub.php | 2 ++ ext/mysqli/mysqli_arginfo.h | 30 +++++++++++++++++-- ext/mysqli/tests/070.phpt | 4 ++- ext/mysqli/tests/071.phpt | 8 ++--- .../tests/mysqli_insert_id_variation.phpt | 3 +- ext/mysqli/tests/mysqli_max_links.phpt | 2 +- ext/mysqli/tests/mysqli_ping.phpt | 8 ++++- ext/mysqli/tests/mysqli_report.phpt | 1 - ext/mysqli/tests/mysqli_report_wo_ps.phpt | 1 - 9 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index 600c2ec80023..6d46e79d5ba8 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -878,6 +878,7 @@ public function next_result(): bool {} * @tentative-return-type * @alias mysqli_ping */ + #[\Deprecated(since: '8.4', message: 'because the reconnect feature has been removed in PHP 8.2 and this method is now redundant')] public function ping(): bool {} /** @@ -1526,6 +1527,7 @@ function mysqli_options(mysqli $mysql, int $option, $value): bool {} */ function mysqli_set_opt(mysqli $mysql, int $option, $value): bool {} +#[\Deprecated(since: '8.4', message: 'because the reconnect feature has been removed in PHP 8.2 and this function is now redundant')] function mysqli_ping(mysqli $mysql): bool {} function mysqli_poll(?array &$read, ?array &$error, array &$reject, int $seconds, int $microseconds = 0): int|false {} diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 2205434e5b65..9b1cb4e61abb 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c401ffa59fcdefc7e47cba88fd0a84495e39c6e7 */ + * Stub hash: 97775c6aba92e347f93a2d38cd41c4769eed738f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING) ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0) @@ -875,7 +875,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(mysqli_num_rows, arginfo_mysqli_num_rows) ZEND_FE(mysqli_options, arginfo_mysqli_options) ZEND_RAW_FENTRY("mysqli_set_opt", zif_mysqli_options, arginfo_mysqli_set_opt, 0, NULL, NULL) - ZEND_FE(mysqli_ping, arginfo_mysqli_ping) + ZEND_RAW_FENTRY("mysqli_ping", zif_mysqli_ping, arginfo_mysqli_ping, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(mysqli_poll, arginfo_mysqli_poll) ZEND_FE(mysqli_prepare, arginfo_mysqli_prepare) ZEND_FE(mysqli_report, arginfo_mysqli_report) @@ -955,7 +955,7 @@ static const zend_function_entry class_mysqli_methods[] = { ZEND_RAW_FENTRY("multi_query", zif_mysqli_multi_query, arginfo_class_mysqli_multi_query, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("more_results", zif_mysqli_more_results, arginfo_class_mysqli_more_results, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("next_result", zif_mysqli_next_result, arginfo_class_mysqli_next_result, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("ping", zif_mysqli_ping, arginfo_class_mysqli_ping, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("ping", zif_mysqli_ping, arginfo_class_mysqli_ping, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_RAW_FENTRY("poll", zif_mysqli_poll, arginfo_class_mysqli_poll, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_RAW_FENTRY("prepare", zif_mysqli_prepare, arginfo_class_mysqli_prepare, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("query", zif_mysqli_query, arginfo_class_mysqli_query, ZEND_ACC_PUBLIC, NULL, NULL) @@ -1171,6 +1171,18 @@ static void register_mysqli_symbols(int module_number) zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_connect", sizeof("mysqli_connect") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); + zend_attribute *attribute_Deprecated_func_mysqli_ping_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_ping", sizeof("mysqli_ping") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED), 2); + zval attribute_Deprecated_func_mysqli_ping_0_arg0; + zend_string *attribute_Deprecated_func_mysqli_ping_0_arg0_str = zend_string_init("8.4", strlen("8.4"), 1); + ZVAL_STR(&attribute_Deprecated_func_mysqli_ping_0_arg0, attribute_Deprecated_func_mysqli_ping_0_arg0_str); + ZVAL_COPY_VALUE(&attribute_Deprecated_func_mysqli_ping_0->args[0].value, &attribute_Deprecated_func_mysqli_ping_0_arg0); + attribute_Deprecated_func_mysqli_ping_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zval attribute_Deprecated_func_mysqli_ping_0_arg1; + zend_string *attribute_Deprecated_func_mysqli_ping_0_arg1_str = zend_string_init("because the reconnect feature has been removed in PHP 8.2 and this function is now redundant", strlen("because the reconnect feature has been removed in PHP 8.2 and this function is now redundant"), 1); + ZVAL_STR(&attribute_Deprecated_func_mysqli_ping_0_arg1, attribute_Deprecated_func_mysqli_ping_0_arg1_str); + ZVAL_COPY_VALUE(&attribute_Deprecated_func_mysqli_ping_0->args[1].value, &attribute_Deprecated_func_mysqli_ping_0_arg1); + attribute_Deprecated_func_mysqli_ping_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_real_connect", sizeof("mysqli_real_connect") - 1), 3, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); zend_attribute *attribute_Deprecated_func_mysqli_refresh_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_refresh", sizeof("mysqli_refresh") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED), 2); @@ -1367,6 +1379,18 @@ static zend_class_entry *register_class_mysqli(void) ZVAL_COPY_VALUE(&attribute_Deprecated_func_init_0->args[1].value, &attribute_Deprecated_func_init_0_arg1); attribute_Deprecated_func_init_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_ping_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "ping", sizeof("ping") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED), 2); + zval attribute_Deprecated_func_ping_0_arg0; + zend_string *attribute_Deprecated_func_ping_0_arg0_str = zend_string_init("8.4", strlen("8.4"), 1); + ZVAL_STR(&attribute_Deprecated_func_ping_0_arg0, attribute_Deprecated_func_ping_0_arg0_str); + ZVAL_COPY_VALUE(&attribute_Deprecated_func_ping_0->args[0].value, &attribute_Deprecated_func_ping_0_arg0); + attribute_Deprecated_func_ping_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zval attribute_Deprecated_func_ping_0_arg1; + zend_string *attribute_Deprecated_func_ping_0_arg1_str = zend_string_init("because the reconnect feature has been removed in PHP 8.2 and this method is now redundant", strlen("because the reconnect feature has been removed in PHP 8.2 and this method is now redundant"), 1); + ZVAL_STR(&attribute_Deprecated_func_ping_0_arg1, attribute_Deprecated_func_ping_0_arg1_str); + ZVAL_COPY_VALUE(&attribute_Deprecated_func_ping_0->args[1].value, &attribute_Deprecated_func_ping_0_arg1); + attribute_Deprecated_func_ping_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "real_connect", sizeof("real_connect") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); zend_attribute *attribute_Deprecated_func_refresh_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "refresh", sizeof("refresh") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED), 2); diff --git a/ext/mysqli/tests/070.phpt b/ext/mysqli/tests/070.phpt index 3f98cd46760c..dcf22399d3bf 100644 --- a/ext/mysqli/tests/070.phpt +++ b/ext/mysqli/tests/070.phpt @@ -15,6 +15,8 @@ require_once 'skipifconnectfailure.inc'; $mysql->close(); print "done!"; ?> ---EXPECT-- +--EXPECTF-- + +Deprecated: Method mysqli::ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this method is now redundant in %s bool(true) done! diff --git a/ext/mysqli/tests/071.phpt b/ext/mysqli/tests/071.phpt index e1d36da47002..ea35156d08af 100644 --- a/ext/mysqli/tests/071.phpt +++ b/ext/mysqli/tests/071.phpt @@ -13,27 +13,27 @@ require_once 'skipifconnectfailure.inc'; $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); $version = $mysql->server_version; - var_dump($mysql->ping()); + var_dump($mysql->query('DO 1')); $ret = $mysql->kill($mysql->thread_id); if ($ret !== true){ printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); } - var_dump($mysql->ping()); + var_dump($mysql->query('DO 1')); $mysql->close(); $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - var_dump(mysqli_ping($mysql)); + var_dump($mysql->query('DO 1')); $ret = $mysql->kill($mysql->thread_id); if ($ret !== true){ printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); } - var_dump(mysqli_ping($mysql)); + var_dump($mysql->query('DO 1')); $mysql->close(); print "done!"; diff --git a/ext/mysqli/tests/mysqli_insert_id_variation.phpt b/ext/mysqli/tests/mysqli_insert_id_variation.phpt index 593cf2ed9ebc..713b66e1f941 100644 --- a/ext/mysqli/tests/mysqli_insert_id_variation.phpt +++ b/ext/mysqli/tests/mysqli_insert_id_variation.phpt @@ -100,5 +100,6 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS test_insert_id_var")) mysqli_close($link); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Method mysqli::ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this method is now redundant in %s DONE diff --git a/ext/mysqli/tests/mysqli_max_links.phpt b/ext/mysqli/tests/mysqli_max_links.phpt index 6c62eaafb746..c2da82d361ba 100644 --- a/ext/mysqli/tests/mysqli_max_links.phpt +++ b/ext/mysqli/tests/mysqli_max_links.phpt @@ -14,7 +14,7 @@ mysqli.max_links=1 require_once 'table.inc'; // to make sure we have at least one working connection... - var_dump(mysqli_ping($link)); + var_dump($link->query('DO 1')); // to make sure that max_links is really set to one var_dump((int)ini_get('mysqli.max_links')); diff --git a/ext/mysqli/tests/mysqli_ping.phpt b/ext/mysqli/tests/mysqli_ping.phpt index 39e2d7de8243..ef1a3e055969 100644 --- a/ext/mysqli/tests/mysqli_ping.phpt +++ b/ext/mysqli/tests/mysqli_ping.phpt @@ -36,8 +36,14 @@ require_once 'skipifconnectfailure.inc'; print "done!"; ?> ---EXPECT-- +--EXPECTF-- + +Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s bool(true) + +Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s bool(true) + +Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_report.phpt b/ext/mysqli/tests/mysqli_report.phpt index b4998546d137..4e1acd19bee6 100644 --- a/ext/mysqli/tests/mysqli_report.phpt +++ b/ext/mysqli/tests/mysqli_report.phpt @@ -41,7 +41,6 @@ require_once 'skipifconnectfailure.inc'; echo $e->getMessage() . \PHP_EOL; } - // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) diff --git a/ext/mysqli/tests/mysqli_report_wo_ps.phpt b/ext/mysqli/tests/mysqli_report_wo_ps.phpt index 681868ad9dc1..ac21b4e378b1 100644 --- a/ext/mysqli/tests/mysqli_report_wo_ps.phpt +++ b/ext/mysqli/tests/mysqli_report_wo_ps.phpt @@ -54,7 +54,6 @@ if (mysqli_get_server_version($link) >= 50600) echo $e->getMessage() . \PHP_EOL; } - // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) printf("[009] select_db should have failed\n");