Skip to content
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 @@ -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 {}

/**
Expand Down Expand Up @@ -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 */
Expand Down
22 changes: 19 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: 4 additions & 2 deletions ext/mysqli/tests/mysqli_change_user_set_names.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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!
4 changes: 1 addition & 3 deletions ext/mysqli/tests/mysqli_fetch_field.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions ext/mysqli/tests/mysqli_fetch_field_oo.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions ext/mysqli/tests/mysqli_fetch_fields.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 3 additions & 4 deletions ext/mysqli/tests/mysqli_field_seek.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
Expand Down
11 changes: 10 additions & 1 deletion ext/mysqli/tests/mysqli_get_charset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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!
5 changes: 3 additions & 2 deletions ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}
}
}
Expand Down
Loading