1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Deprecate mysqli_ping (#11945)

This commit is contained in:
Kamil Tekiela
2024-08-09 18:32:21 +02:00
committed by GitHub
parent 00001c4a0c
commit cbcad9fdaf
9 changed files with 46 additions and 13 deletions

View File

@@ -878,6 +878,7 @@ class mysqli
* @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 {}

View File

@@ -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);

View File

@@ -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!

View File

@@ -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!";

View File

@@ -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

View File

@@ -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'));

View File

@@ -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!

View File

@@ -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"))

View File

@@ -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");