Skip to content

Commit c9c5ee3

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-8253: pg_insert() fails for references
2 parents a6d88d3 + 7e8dcda commit c9c5ee3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

ext/pgsql/pgsql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4584,6 +4584,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
45844584

45854585
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), field, val) {
45864586
skip_field = 0;
4587+
ZVAL_DEREF(val);
45874588
ZVAL_NULL(&new_val);
45884589

45894590
/* TODO: Check when meta data can be broken and see if can use assertions instead */

ext/pgsql/tests/gh8253.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
pg_insert() fails for references
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php
7+
include("skipif.inc");
8+
?>
9+
--FILE--
10+
<?php
11+
include "config.inc";
12+
13+
function fee(&$a) {}
14+
$a = ["bar" => "testing"];
15+
fee($a["bar"]);
16+
17+
$db = pg_connect($conn_str);
18+
pg_query($db, "DROP TABLE IF EXISTS gh8253");
19+
pg_query($db, "CREATE TABLE gh8253 (bar text);");
20+
pg_insert($db, "gh8253", $a);
21+
$res = pg_query($db, "SELECT * FROM gh8253");
22+
var_dump(pg_fetch_all($res));
23+
?>
24+
--EXPECT--
25+
array(1) {
26+
[0]=>
27+
array(1) {
28+
["bar"]=>
29+
string(7) "testing"
30+
}
31+
}

0 commit comments

Comments
 (0)