From 407034fe1c574ff2dc27028bf33a47e805d7f1c3 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Thu, 12 Nov 2026 09:04:54 +0100 Subject: [PATCH] ext/pgsql: do not print an object address as the result index in the row warnings The "Unable to jump to row" warning of pg_fetch_result(), pg_fetch_row(), pg_field_prtlen() and pg_field_is_null() appended Z_LVAL_P() of a PgSql\Result object as a "result index", which is the object address. Drop the operand. --- ext/pgsql/pgsql.c | 9 ++--- ext/pgsql/tests/pg_error_message_text.phpt | 39 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 ext/pgsql/tests/pg_error_message_text.phpt diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 2eb2d6b306e7..a391a3753aee 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1923,8 +1923,7 @@ PHP_FUNCTION(pg_fetch_result) RETURN_THROWS(); } if (row >= PQntuples(pgsql_result)) { - php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT, - row, Z_LVAL_P(result)); + php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row); RETURN_FALSE; } pgsql_row = (int)row; @@ -1972,8 +1971,7 @@ static bool php_pgsql_fetch_hash(zval *return_value, const zval *result, zend_lo if (!row_is_null) { if (row >= PQntuples(pgsql_result)) { - php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT, - row, Z_LVAL_P(result)); + php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row); return false; } pgsql_row = (int)row; @@ -2312,8 +2310,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type, bo RETURN_THROWS(); } if (row >= PQntuples(pgsql_result)) { - php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT, - row, Z_LVAL_P(result)); + php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row); RETURN_FALSE; } pgsql_row = (int)row; diff --git a/ext/pgsql/tests/pg_error_message_text.phpt b/ext/pgsql/tests/pg_error_message_text.phpt new file mode 100644 index 000000000000..99f31349c007 --- /dev/null +++ b/ext/pgsql/tests/pg_error_message_text.phpt @@ -0,0 +1,39 @@ +--TEST-- +The row diagnostics print no object address +--EXTENSIONS-- +pgsql +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: pg_fetch_result(): Unable to jump to row 99 in %s on line %d +bool(false) + +Warning: pg_fetch_row(): Unable to jump to row 99 in %s on line %d +bool(false) + +Warning: pg_field_prtlen(): Unable to jump to row 99 in %s on line %d +bool(false) + +Warning: pg_field_is_null(): Unable to jump to row 99 in %s on line %d +bool(false)