Skip to content

Redesign client_info and client_version in mysqli #6777

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

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ PHP 8.1 UPGRADE NOTES
. The mysqli_driver::$driver_version property has been deprecated. The driver
version is meaningless as it hasn't been updated in more than a decade. Use
PHP_VERSION_ID instead.
. Calling mysqli::get_client_info in OO style or passing $mysqli argument to
mysqli_get_client_info() function has been deprecated. Use
mysqli_get_client_info() without any arguments to obtain the client
library version information.

========================================
5. Changed Functions
Expand Down
1 change: 1 addition & 0 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function get_charset() {}
/**
* @return string|null
* @alias mysqli_get_client_info
* @deprecated 8.1.0
*/
public function get_client_info() {}

Expand Down
4 changes: 4 additions & 0 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,10 @@ PHP_FUNCTION(mysqli_get_client_info)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &mysql_link, mysqli_link_class_entry) == FAILURE) {
RETURN_THROWS();
}

if (ZEND_NUM_ARGS()) {
php_error_docref(NULL, E_DEPRECATED, "Passing connection object as an argument is deprecated");
}
}

RETURN_STRING(mysql_get_client_info());
Expand Down
4 changes: 2 additions & 2 deletions ext/mysqli/mysqli_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 56499df713b79c1e9efc19cf8be45aa98028172c */
* Stub hash: e65b3497e7783d55f3dfd4cd89be65094c59b1d3 */

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)
Expand Down Expand Up @@ -938,7 +938,7 @@ static const zend_function_entry class_mysqli_methods[] = {
ZEND_ME_MAPPING(dump_debug_info, mysqli_dump_debug_info, arginfo_class_mysqli_dump_debug_info, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(debug, mysqli_debug, arginfo_class_mysqli_debug, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(get_charset, mysqli_get_charset, arginfo_class_mysqli_get_charset, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
#if defined(MYSQLI_USE_MYSQLND)
ZEND_ME_MAPPING(get_connection_stats, mysqli_get_connection_stats, arginfo_class_mysqli_get_connection_stats, ZEND_ACC_PUBLIC)
#endif
Expand Down
4 changes: 2 additions & 2 deletions ext/mysqli/tests/bug36802.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Bug #36802 (crashes with with mysqli_set_charset())
}

/* following operations should work */
$x[1] = ($mysql->client_version > 0);
$x[1] = ($mysql->error);
$x[2] = $mysql->errno;

$mysql->close();
Expand All @@ -43,7 +43,7 @@ mysqli object is not fully initialized
mysqli object is not fully initialized
array(2) {
[1]=>
bool(true)
string(0) ""
[2]=>
int(0)
}
31 changes: 31 additions & 0 deletions ext/mysqli/tests/mysqli_get_info_deprecations.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
Deprecated messages for mysqli::get_client_info() method
--SKIPIF--
<?php
require_once 'skipif.inc';
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require 'connect.inc';

if (!$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
}

printf("client_info = '%s'\n", $mysqli->get_client_info());

printf("client_info = '%s'\n", mysqli_get_client_info($mysqli));

print "done!";
?>
--EXPECTF--

Deprecated: Method mysqli::get_client_info() is deprecated in %s
client_info = '%s'

Deprecated: mysqli_get_client_info(): Passing connection object as an argument is deprecated in %s
client_info = '%s'
done!