Skip to content

Commit

Permalink
Fix phpGH-12763: PGSQL pg_untrace(): Argument #1 ($connection) must b…
Browse files Browse the repository at this point in the history
…e of type resource or null, PgSql\Connection given.
  • Loading branch information
degtyaryov authored and devnexen committed Nov 27, 2023
1 parent 7e7817b commit 3f57bd8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ PHP NEWS
- PCRE:
. Fixed bug GH-12628 (The gh11374 test fails on Alpinelinux). (nielsdos)

- PGSQL:
. Fixed bug GH-12763 wrong argument type for pg_untrace. (degtyarov)

- PHPDBG:
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)

Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ PHP_FUNCTION(pg_untrace)
PGconn *pgsql;
pgsql_link_handle *link;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r!", &pgsql_link) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}

Expand Down
23 changes: 23 additions & 0 deletions ext/pgsql/tests/gh12763.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Bug #GH12763 (pg_untrace(): Argument #1 ($connection) must be of type resource or null, PgSql\Connection given)
--EXTENSIONS--
pgsql
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php
include('config.inc');

$conn = pg_connect($conn_str);

$file_name = tempnam('.', 'trace.log');
pg_trace($file_name, 'w', $conn);
pg_query($conn, 'select 1 as a');
pg_untrace($conn);
$items = explode("\n", file_get_contents($file_name));
unlink($file_name);
echo isset($items[0]) ? 'OK' : 'FAIL';

?>
--EXPECT--
OK

0 comments on commit 3f57bd8

Please sign in to comment.