diff --git a/NEWS b/NEWS index cea490779d7..92ac43c9854 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ PHP NEWS - PgSQL: . Fixed result_type related stack corruption on LLP64 architectures. (cmb) + . Fixed bug GH-8253 (pg_insert() fails for references). (cmb) - Sockets: . Fixed Solaris builds. (David Carlier) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 5ef852af8dd..4cc2b7a0857 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -4584,6 +4584,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string * ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), field, val) { skip_field = 0; + ZVAL_DEREF(val); ZVAL_NULL(&new_val); /* TODO: Check when meta data can be broken and see if can use assertions instead */ diff --git a/ext/pgsql/tests/gh8253.phpt b/ext/pgsql/tests/gh8253.phpt new file mode 100644 index 00000000000..b8732fd0d8d --- /dev/null +++ b/ext/pgsql/tests/gh8253.phpt @@ -0,0 +1,31 @@ +--TEST-- +pg_insert() fails for references +--EXTENSIONS-- +pgsql +--SKIPIF-- + +--FILE-- + "testing"]; +fee($a["bar"]); + +$db = pg_connect($conn_str); +pg_query($db, "DROP TABLE IF EXISTS gh8253"); +pg_query($db, "CREATE TABLE gh8253 (bar text);"); +pg_insert($db, "gh8253", $a); +$res = pg_query($db, "SELECT * FROM gh8253"); +var_dump(pg_fetch_all($res)); +?> +--EXPECT-- +array(1) { + [0]=> + array(1) { + ["bar"]=> + string(7) "testing" + } +}