Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fix GH-17158: pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument
  • Loading branch information
nielsdos committed Dec 14, 2024
2 parents 7bfd198 + e562b8c commit 57e9429
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions ext/pgsql/tests/gh17158.phpt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 57e9429

Please sign in to comment.