diff options
author | Dharman <tekiela246@gmail.com> | 2021-03-13 17:34:33 +0000 |
---|---|---|
committer | Dharman <tekiela246@gmail.com> | 2021-03-17 20:10:18 +0000 |
commit | 7e9f6d2a48f8ff6ae458252d395eec1b1d9e6f14 (patch) | |
tree | 97ba101d228e2a8042c621599d5ac4fe67abaa73 | |
parent | eb8f5e43475e44f8746a2357ed8c3cd60b426eb0 (diff) | |
download | php-git-7e9f6d2a48f8ff6ae458252d395eec1b1d9e6f14.tar.gz |
Deprecate OO style mysqli::get_client_info method
Deprecate passing connection object to mysqli_get_client_info()
Closes GH-6777.
-rw-r--r-- | UPGRADING | 4 | ||||
-rw-r--r-- | ext/mysqli/mysqli.stub.php | 1 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 4 | ||||
-rw-r--r-- | ext/mysqli/mysqli_arginfo.h | 4 | ||||
-rw-r--r-- | ext/mysqli/tests/bug36802.phpt | 4 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_get_info_deprecations.phpt | 31 |
6 files changed, 44 insertions, 4 deletions
@@ -223,6 +223,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 diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index 9956778c6e..5152e7f911 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -136,6 +136,7 @@ class mysqli /** * @return string|null * @alias mysqli_get_client_info + * @deprecated 8.1.0 */ public function get_client_info() {} diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index e1abd07135..728e785478 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -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()); diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 9c55a6bfc8..b607b5ae36 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: 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) @@ -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 diff --git a/ext/mysqli/tests/bug36802.phpt b/ext/mysqli/tests/bug36802.phpt index 1189115837..c0bace8aaf 100644 --- a/ext/mysqli/tests/bug36802.phpt +++ b/ext/mysqli/tests/bug36802.phpt @@ -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(); @@ -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) } diff --git a/ext/mysqli/tests/mysqli_get_info_deprecations.phpt b/ext/mysqli/tests/mysqli_get_info_deprecations.phpt new file mode 100644 index 0000000000..2dbbce0540 --- /dev/null +++ b/ext/mysqli/tests/mysqli_get_info_deprecations.phpt @@ -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! |