1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix GH-17158: pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument
This commit is contained in:
Niels Dossche
2024-12-14 19:49:12 +01:00
2 changed files with 20 additions and 1 deletions

View File

@@ -1894,7 +1894,7 @@ PHP_FUNCTION(pg_fetch_result)
Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
Z_PARAM_STR_OR_LONG(field_name, field_offset)
ZEND_PARSE_PARAMETERS_END();
} else {
} else if (ZEND_NUM_ARGS() == 3) {
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
if (zend_string_equals_literal(EG(current_execute_data)->func->common.function_name, "pg_result")) {
@@ -1904,6 +1904,9 @@ PHP_FUNCTION(pg_fetch_result)
}
Z_PARAM_STR_OR_LONG(field_name, field_offset)
ZEND_PARSE_PARAMETERS_END();
} else {
zend_wrong_parameters_count_error(2, 3);
RETURN_THROWS();
}
pg_result = Z_PGSQL_RESULT_P(result);

View File

@@ -0,0 +1,16 @@
--TEST--
GH-17158 (pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument)
--EXTENSIONS--
pgsql
--FILE--
<?php
try {
pg_fetch_result(null);
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
pg_fetch_result() expects at least 2 arguments, 1 given