diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index cc6b8c57404a..c995cf564a57 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -797,6 +797,7 @@ public function debug(string $options): true {} * @tentative-return-type * @alias mysqli_get_charset */ + #[\Deprecated(since: '8.6', message: 'did you mean mysqli_character_set_name()?')] public function get_charset(): ?object {} /** @@ -1463,6 +1464,7 @@ function mysqli_get_connection_stats(mysqli $mysql): array {} function mysqli_get_client_stats(): array {} /** @refcount 1 */ +#[\Deprecated(since: '8.6', message: 'did you mean mysqli_character_set_name()?')] function mysqli_get_charset(mysqli $mysql): ?object {} /** @refcount 1 */ diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 0121f36f3cfd..1fd84063441e 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit mysqli.stub.php instead. - * Stub hash: dc804bc50cd0a0e14dafc0e03564d5699d641db0 */ + * Stub hash: d31c6ff508415337f4536e8e476168882e769158 */ 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) @@ -862,7 +862,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(mysqli_free_result, arginfo_mysqli_free_result) ZEND_FE(mysqli_get_connection_stats, arginfo_mysqli_get_connection_stats) ZEND_FE(mysqli_get_client_stats, arginfo_mysqli_get_client_stats) - ZEND_FE(mysqli_get_charset, arginfo_mysqli_get_charset) + ZEND_RAW_FENTRY("mysqli_get_charset", zif_mysqli_get_charset, arginfo_mysqli_get_charset, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(mysqli_get_client_info, arginfo_mysqli_get_client_info) ZEND_FE(mysqli_get_client_version, arginfo_mysqli_get_client_version) ZEND_FE(mysqli_get_links_stats, arginfo_mysqli_get_links_stats) @@ -948,7 +948,7 @@ static const zend_function_entry class_mysqli_methods[] = { ZEND_RAW_FENTRY("connect", zif_mysqli_connect, arginfo_class_mysqli_connect, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("dump_debug_info", zif_mysqli_dump_debug_info, arginfo_class_mysqli_dump_debug_info, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("debug", zif_mysqli_debug, arginfo_class_mysqli_debug, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("get_charset", zif_mysqli_get_charset, arginfo_class_mysqli_get_charset, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("get_charset", zif_mysqli_get_charset, arginfo_class_mysqli_get_charset, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_RAW_FENTRY("execute_query", zif_mysqli_execute_query, arginfo_class_mysqli_execute_query, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("get_client_info", zif_mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_RAW_FENTRY("get_connection_stats", zif_mysqli_get_connection_stats, arginfo_class_mysqli_get_connection_stats, ZEND_ACC_PUBLIC, NULL, NULL) @@ -1167,6 +1167,14 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_func_mysqli_execute_0->args[1].value, attribute_Deprecated_func_mysqli_execute_0_arg1_str); attribute_Deprecated_func_mysqli_execute_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_mysqli_get_charset_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_get_charset", sizeof("mysqli_get_charset") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + zend_string *attribute_Deprecated_func_mysqli_get_charset_0_arg0_str = zend_string_init("8.6", strlen("8.6"), 1); + ZVAL_STR(&attribute_Deprecated_func_mysqli_get_charset_0->args[0].value, attribute_Deprecated_func_mysqli_get_charset_0_arg0_str); + attribute_Deprecated_func_mysqli_get_charset_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_mysqli_get_charset_0_arg1_str = zend_string_init("did you mean mysqli_character_set_name()?", strlen("did you mean mysqli_character_set_name()?"), 1); + ZVAL_STR(&attribute_Deprecated_func_mysqli_get_charset_0->args[1].value, attribute_Deprecated_func_mysqli_get_charset_0_arg1_str); + attribute_Deprecated_func_mysqli_get_charset_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_mysqli_kill_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_kill", sizeof("mysqli_kill") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); ZVAL_STR(&attribute_Deprecated_func_mysqli_kill_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_4)); attribute_Deprecated_func_mysqli_kill_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); @@ -1459,6 +1467,14 @@ static zend_class_entry *register_class_mysqli(void) zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "connect", sizeof("connect") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); + zend_attribute *attribute_Deprecated_func_get_charset_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "get_charset", sizeof("get_charset") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + zend_string *attribute_Deprecated_func_get_charset_0_arg0_str = zend_string_init("8.6", strlen("8.6"), 1); + ZVAL_STR(&attribute_Deprecated_func_get_charset_0->args[0].value, attribute_Deprecated_func_get_charset_0_arg0_str); + attribute_Deprecated_func_get_charset_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_get_charset_0_arg1_str = zend_string_init("did you mean mysqli_character_set_name()?", strlen("did you mean mysqli_character_set_name()?"), 1); + ZVAL_STR(&attribute_Deprecated_func_get_charset_0->args[1].value, attribute_Deprecated_func_get_charset_0_arg1_str); + attribute_Deprecated_func_get_charset_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_get_client_info_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "get_client_info", sizeof("get_client_info") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); ZVAL_STR(&attribute_Deprecated_func_get_client_info_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_1)); attribute_Deprecated_func_get_client_info_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); diff --git a/ext/mysqli/tests/mysqli_change_user_set_names.phpt b/ext/mysqli/tests/mysqli_change_user_set_names.phpt index bcf957942f57..978150c3cbc6 100644 --- a/ext/mysqli/tests/mysqli_change_user_set_names.phpt +++ b/ext/mysqli/tests/mysqli_change_user_set_names.phpt @@ -125,11 +125,12 @@ require_once 'skipifconnectfailure.inc'; if (!is_object($charset = mysqli_get_charset($link))) printf("[013] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); - if ($charset->charset != $defaults['charset_connection']) + if ($charset->charset != $defaults['charset_connection'] || $link->character_set_name() != $defaults['charset_connection']) printf("[014] Expecting connection charset to be %s got %s\n", $defaults['charset_connection'], $charset->charset); + // Remove the following test when removing mysqli_get_charset() in PHP 9.0.0 if ($charset->collation != $defaults['collation_connection']) printf("[015] Expecting collation to be %s got %s\n", $defaults['collation_connection'], @@ -138,5 +139,6 @@ require_once 'skipifconnectfailure.inc'; mysqli_close($link); print "done!"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in %s on line %d done! diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt index e65de2308ab4..7519e572bb55 100644 --- a/ext/mysqli/tests/mysqli_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field.phpt @@ -15,9 +15,7 @@ require_once 'skipifconnectfailure.inc'; // Make sure that client, connection and result charsets are all the // same. Not sure whether this is strictly necessary. if (!mysqli_set_charset($link, 'utf8')) - printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - - $charsetInfo = mysqli_get_charset($link); + printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt index 0f2a6c55841e..ad8f0439568d 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt @@ -15,9 +15,7 @@ require_once 'skipifconnectfailure.inc'; // Make sure that client, connection and result charsets are all the // same. Not sure whether this is strictly necessary. if (!$mysqli->set_charset('utf8')) - printf("[%d] %s\n", $mysqli->errno, $mysqli->errno); - - $charsetInfo = $mysqli->get_charset(); + printf("[%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt index 2257c4d9d060..18e2fc7fe9af 100644 --- a/ext/mysqli/tests/mysqli_fetch_fields.phpt +++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt @@ -15,9 +15,7 @@ require_once 'skipifconnectfailure.inc'; // Make sure that client, connection and result charsets are all the // same. Not sure whether this is strictly necessary. if (!mysqli_set_charset($link, 'utf8')) - printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - - $charsetInfo = mysqli_get_charset($link); + printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index af52bf6c97fb..f9fe55aaf76e 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -61,8 +61,6 @@ require_once 'skipifconnectfailure.inc'; if (!mysqli_set_charset($link, 'utf8')) printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - $charsetInfo = mysqli_get_charset($link); - if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } @@ -80,9 +78,10 @@ require_once 'skipifconnectfailure.inc'; $field = mysqli_fetch_field($res); var_dump($field); /* label column, result set charset */ - if ($field->length != $charsetInfo->max_length) { + $charMaxLength = 3; + if ($field->length != $charMaxLength) { printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, $field->max_length); + $charMaxLength, $field->max_length); } var_dump(mysqli_field_tell($res)); diff --git a/ext/mysqli/tests/mysqli_get_charset.phpt b/ext/mysqli/tests/mysqli_get_charset.phpt index 2752084372a9..4753823227d8 100644 --- a/ext/mysqli/tests/mysqli_get_charset.phpt +++ b/ext/mysqli/tests/mysqli_get_charset.phpt @@ -72,6 +72,10 @@ require_once 'skipifconnectfailure.inc'; !is_int($charset->state)) printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); + $charsetOO = $link->get_charset(); + if ($charsetOO != $charset) + printf("[023] Expecting object/%s, got %s/%s\n", gettype($charset), gettype($charsetOO), $charsetOO); + mysqli_close($link); try { @@ -82,6 +86,11 @@ require_once 'skipifconnectfailure.inc'; print "done!"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in %s on line %d + +Deprecated: Method mysqli::get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in %s on line %d + +Deprecated: Function mysqli_get_charset() is deprecated since 8.6, did you mean mysqli_character_set_name()? in %s on line %d mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt index 935e541b7897..766b105dcb6c 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt @@ -24,7 +24,8 @@ if (mysqli_get_server_version($link) <= 50000) { if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) printf("[009] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { + // The test fails on MariaDB when the version string is too long, so keep it at least 50 + if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(50)) BEGIN SELECT VERSION() INTO ver_param; END;')) { /* no result set, one output parameter */ if (!$stmt = mysqli_prepare($link, 'CALL p(@version)')) printf("[011] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -66,7 +67,7 @@ if (mysqli_get_server_version($link) <= 50000) { if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) printf("[019] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { + if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(50)) BEGIN SELECT VERSION() INTO ver_param; END;')) { // no result set, one output parameter if (!$stmt = mysqli_prepare($link, 'CALL p(@version)')) printf("[020] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt index 600c8ae47993..4cf36a58591c 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt @@ -15,8 +15,6 @@ require_once 'skipifconnectfailure.inc'; if (!mysqli_set_charset($link, 'utf8')) printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - $charsetInfo = mysqli_get_charset($link); - if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label, id + 1 as _id, concat(label, '_') ___label FROM test ORDER BY id ASC LIMIT 3") || !mysqli_stmt_execute($stmt)) @@ -42,9 +40,10 @@ require_once 'skipifconnectfailure.inc'; Label column, result set charset. All of the following columns are "too hot" - too server dependent */ - if ($field->length != $charsetInfo->max_length) { + $charMaxLength = 3; + if ($field->length != $charMaxLength) { printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, $field->max_length); + $charMaxLength, $field->max_length); } } }