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'

This commit is contained in:
David Carlier
2024-12-15 14:56:29 +00:00
2 changed files with 97 additions and 8 deletions

View File

@@ -1136,7 +1136,7 @@ PHP_FUNCTION(pg_query)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 2) {
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(query, query_len)
@@ -1144,6 +1144,9 @@ PHP_FUNCTION(pg_query)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(1, 2);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -1234,7 +1237,7 @@ PHP_FUNCTION(pg_query_params)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 3) {
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(query, query_len)
@@ -1243,6 +1246,9 @@ PHP_FUNCTION(pg_query_params)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(2, 3);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -1344,7 +1350,7 @@ PHP_FUNCTION(pg_prepare)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 3) {
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(stmtname, stmtname_len)
@@ -1353,6 +1359,9 @@ PHP_FUNCTION(pg_prepare)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(2, 3);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -1430,7 +1439,7 @@ PHP_FUNCTION(pg_execute)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 3) {
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(stmtname, stmtname_len)
@@ -1439,6 +1448,9 @@ PHP_FUNCTION(pg_execute)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(2, 3);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -2230,7 +2242,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type, bo
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 (nullable_row) {
@@ -2240,6 +2252,9 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type, bo
}
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);
@@ -3070,7 +3085,7 @@ PHP_FUNCTION(pg_set_error_verbosity)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 2) {
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_LONG(verbosity)
@@ -3078,6 +3093,9 @@ PHP_FUNCTION(pg_set_error_verbosity)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(1, 2);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -3148,7 +3166,7 @@ PHP_FUNCTION(pg_set_client_encoding)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 2) {
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(encoding, encoding_len)
@@ -3156,6 +3174,9 @@ PHP_FUNCTION(pg_set_client_encoding)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(1, 2);
RETURN_THROWS();
}
pgsql = link->conn;
@@ -3242,7 +3263,7 @@ PHP_FUNCTION(pg_put_line)
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
} else if (ZEND_NUM_ARGS() == 2) {
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_STRING(query, query_len)
@@ -3250,6 +3271,9 @@ PHP_FUNCTION(pg_put_line)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
} else {
zend_wrong_parameters_count_error(1, 2);
RETURN_THROWS();
}
pgsql = link->conn;

View File

@@ -0,0 +1,65 @@
--TEST--
Fix pg_query()/pg_query_params()/pg_prepare()/pg_execute()/pg_set_error_verbosity()/pg_set_client_encoding()/pg_put_line() pg field infos calls ArgumentCountError message.
--EXTENSIONS--
pgsql
--SKIPIF--
<?php
include("skipif.inc");
?>
--FILE--
<?php
include "config.inc";
$db = pg_connect($conn_str);
try {
pg_query("a", "b", "c");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_query_params($db, "b", array(), "d");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_prepare($db, "a", "b", "c");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_set_error_verbosity($db, 0, PHP_INT_MAX);
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_set_client_encoding($db, "foo", "bar");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_put_line($db, "my", "data");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
pg_field_is_null($db, false, "myfield", new stdClass());
} catch (ArgumentCountError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
pg_query() expects at most 2 arguments, 3 given
pg_query_params() expects at most 3 arguments, 4 given
pg_prepare() expects at most 3 arguments, 4 given
pg_set_error_verbosity() expects at most 2 arguments, 3 given
pg_set_client_encoding() expects at most 2 arguments, 3 given
pg_put_line() expects at most 2 arguments, 3 given
pg_field_is_null() expects at most 3 arguments, 4 given