Skip to content

Commit

Permalink
Merge branch 'PHP-8.3' into PHP-8.4
Browse files Browse the repository at this point in the history
* PHP-8.3:
  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 0cc0c7c + 388f63c commit e562b8c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ PHP NEWS
- Opcache:
. opcache_get_configuration() properly reports jit_prof_threshold. (cmb)

- PgSql:
. Fixed bug GH-17158 (pg_fetch_result Shows Incorrect ArgumentCountError
Message when Called With 1 Argument). (nielsdos)

- SimpleXML:
. Fixed bug GH-17040 (SimpleXML's unset can break DOM objects). (nielsdos)

Expand Down
5 changes: 4 additions & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,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 @@ -1903,6 +1903,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 e562b8c

Please sign in to comment.