Skip to content

Commit 7e9f6d2

Browse files
committed
Deprecate OO style mysqli::get_client_info method
Deprecate passing connection object to mysqli_get_client_info() Closes phpGH-6777.
1 parent eb8f5e4 commit 7e9f6d2

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ PHP 8.1 UPGRADE NOTES
223223
. The mysqli_driver::$driver_version property has been deprecated. The driver
224224
version is meaningless as it hasn't been updated in more than a decade. Use
225225
PHP_VERSION_ID instead.
226+
. Calling mysqli::get_client_info in OO style or passing $mysqli argument to
227+
mysqli_get_client_info() function has been deprecated. Use
228+
mysqli_get_client_info() without any arguments to obtain the client
229+
library version information.
226230

227231
========================================
228232
5. Changed Functions

ext/mysqli/mysqli.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public function get_charset() {}
136136
/**
137137
* @return string|null
138138
* @alias mysqli_get_client_info
139+
* @deprecated 8.1.0
139140
*/
140141
public function get_client_info() {}
141142

ext/mysqli/mysqli_api.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,10 @@ PHP_FUNCTION(mysqli_get_client_info)
13271327
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &mysql_link, mysqli_link_class_entry) == FAILURE) {
13281328
RETURN_THROWS();
13291329
}
1330+
1331+
if (ZEND_NUM_ARGS()) {
1332+
php_error_docref(NULL, E_DEPRECATED, "Passing connection object as an argument is deprecated");
1333+
}
13301334
}
13311335

13321336
RETURN_STRING(mysql_get_client_info());

ext/mysqli/mysqli_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 56499df713b79c1e9efc19cf8be45aa98028172c */
2+
* Stub hash: e65b3497e7783d55f3dfd4cd89be65094c59b1d3 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
55
ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
@@ -938,7 +938,7 @@ static const zend_function_entry class_mysqli_methods[] = {
938938
ZEND_ME_MAPPING(dump_debug_info, mysqli_dump_debug_info, arginfo_class_mysqli_dump_debug_info, ZEND_ACC_PUBLIC)
939939
ZEND_ME_MAPPING(debug, mysqli_debug, arginfo_class_mysqli_debug, ZEND_ACC_PUBLIC)
940940
ZEND_ME_MAPPING(get_charset, mysqli_get_charset, arginfo_class_mysqli_get_charset, ZEND_ACC_PUBLIC)
941-
ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC)
941+
ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
942942
#if defined(MYSQLI_USE_MYSQLND)
943943
ZEND_ME_MAPPING(get_connection_stats, mysqli_get_connection_stats, arginfo_class_mysqli_get_connection_stats, ZEND_ACC_PUBLIC)
944944
#endif

ext/mysqli/tests/bug36802.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Bug #36802 (crashes with with mysqli_set_charset())
3131
}
3232

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

3737
$mysql->close();
@@ -43,7 +43,7 @@ mysqli object is not fully initialized
4343
mysqli object is not fully initialized
4444
array(2) {
4545
[1]=>
46-
bool(true)
46+
string(0) ""
4747
[2]=>
4848
int(0)
4949
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Deprecated messages for mysqli::get_client_info() method
3+
--SKIPIF--
4+
<?php
5+
require_once 'skipif.inc';
6+
require_once 'skipifconnectfailure.inc';
7+
?>
8+
--FILE--
9+
<?php
10+
require 'connect.inc';
11+
12+
if (!$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13+
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
14+
$host, $user, $db, $port, $socket);
15+
exit(1);
16+
}
17+
18+
printf("client_info = '%s'\n", $mysqli->get_client_info());
19+
20+
printf("client_info = '%s'\n", mysqli_get_client_info($mysqli));
21+
22+
print "done!";
23+
?>
24+
--EXPECTF--
25+
26+
Deprecated: Method mysqli::get_client_info() is deprecated in %s
27+
client_info = '%s'
28+
29+
Deprecated: mysqli_get_client_info(): Passing connection object as an argument is deprecated in %s
30+
client_info = '%s'
31+
done!

0 commit comments

Comments
 (0)