Skip to content

Commit 55fd97c

Browse files
committed
Fix #78790: mysqli_get_client_info() expects exactly 0 parameters, 1 given
Although the `mysqli` parameter is unused, it had been accepted so far, and the documentation even claims that parameter would be required. To not break BC, we allow it again.
1 parent e1b5731 commit 55fd97c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,16 @@ PHP_FUNCTION(mysqli_free_result)
13741374
Get MySQL client info */
13751375
PHP_FUNCTION(mysqli_get_client_info)
13761376
{
1377-
if (zend_parse_parameters_none() == FAILURE) {
1378-
return;
1377+
if (getThis()) {
1378+
if (zend_parse_parameters_none() == FAILURE) {
1379+
return;
1380+
}
1381+
} else {
1382+
zval *mysql_link;
1383+
1384+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
1385+
return;
1386+
}
13791387
}
13801388

13811389
const char * info = mysql_get_client_info();

ext/mysqli/mysqli_fe.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_only_link, 0, 0, 1)
7474
MYSQLI_ZEND_ARG_OBJ_INFO_LINK()
7575
ZEND_END_ARG_INFO()
7676

77+
ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_optional_link, 0, 0, 0)
78+
MYSQLI_ZEND_ARG_OBJ_INFO_LINK()
79+
ZEND_END_ARG_INFO()
80+
7781
ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_autocommit, 0, 0, 2)
7882
MYSQLI_ZEND_ARG_OBJ_INFO_LINK()
7983
ZEND_ARG_INFO(0, mode)
@@ -445,7 +449,7 @@ const zend_function_entry mysqli_functions[] = {
445449
#ifdef HAVE_MYSQLI_GET_CHARSET
446450
PHP_FE(mysqli_get_charset, arginfo_mysqli_only_link)
447451
#endif
448-
PHP_FE(mysqli_get_client_info, arginfo_mysqli_no_options)
452+
PHP_FE(mysqli_get_client_info, arginfo_mysqli_optional_link)
449453
PHP_FE(mysqli_get_client_version, arginfo_mysqli_no_options)
450454
PHP_FE(mysqli_get_links_stats, arginfo_mysqli_no_options)
451455
PHP_FE(mysqli_get_host_info, arginfo_mysqli_only_link)

ext/mysqli/tests/bug74737.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ echo PHP_EOL;
1313
echo $rf->getNumberOfRequiredParameters();
1414
?>
1515
--EXPECT--
16-
0
16+
1
1717
0

0 commit comments

Comments
 (0)