[php-src] Issue #8253: pg_insert fails if one of the values has been passed by reference
| From: | dansmill | Date: | Sat, 26 Mar 2022 05:29:13 +0000 |
| Subject: | [php-src] Issue #8253: pg_insert fails if one of the values has been passed by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240507@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8253
Author: dansmill
### Description
In a test postgresql database create a table like such:
```
create table foo ( bar text );
```
The following code:
```php
<?php
function fee(&$a){}
$a = ["bar"=>"testing"];
$db = pg_connect('dbname=test host=localhost');
pg_insert($db, 'foo', $a); //No error
$res = pg_query($db, "select * from foo");
var_dump(pg_fetch_all($res)); // Output is a single tuple with the field foo is "testing"
fee($a["bar"]);
pg_insert($db, 'foo', $a); //Error: pg_insert(): Expects NULL, string, long or double
value for PostgreSQL 'text' (bar)
```
I can reproduce on 7.1 and 8.0
There is no error on 5.6.
### PHP Version
PHP 8.0.3
### Operating System
Rocky Linux release 8.4