Skip to content

Commit 3f57bd8

Browse files
degtyaryovdevnexen
authored andcommitted
Fix phpGH-12763: PGSQL pg_untrace(): Argument #1 ($connection) must be of type resource or null, PgSql\Connection given.
1 parent 7e7817b commit 3f57bd8

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ PHP NEWS
3030
- PCRE:
3131
. Fixed bug GH-12628 (The gh11374 test fails on Alpinelinux). (nielsdos)
3232

33+
- PGSQL:
34+
. Fixed bug GH-12763 wrong argument type for pg_untrace. (degtyarov)
35+
3336
- PHPDBG:
3437
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)
3538

ext/pgsql/pgsql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ PHP_FUNCTION(pg_untrace)
22862286
PGconn *pgsql;
22872287
pgsql_link_handle *link;
22882288

2289-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r!", &pgsql_link) == FAILURE) {
2289+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
22902290
RETURN_THROWS();
22912291
}
22922292

ext/pgsql/tests/gh12763.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #GH12763 (pg_untrace(): Argument #1 ($connection) must be of type resource or null, PgSql\Connection given)
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php include("skipif.inc"); ?>
7+
--FILE--
8+
<?php
9+
include('config.inc');
10+
11+
$conn = pg_connect($conn_str);
12+
13+
$file_name = tempnam('.', 'trace.log');
14+
pg_trace($file_name, 'w', $conn);
15+
pg_query($conn, 'select 1 as a');
16+
pg_untrace($conn);
17+
$items = explode("\n", file_get_contents($file_name));
18+
unlink($file_name);
19+
echo isset($items[0]) ? 'OK' : 'FAIL';
20+
21+
?>
22+
--EXPECT--
23+
OK

0 commit comments

Comments
 (0)