Bug #72028 [NEW]: pg_query_params(): NULL converts to empty string

From: Date: Fri, 15 Apr 2016 09:25:14 +0000
Subject: Bug #72028 [NEW]: pg_query_params(): NULL converts to empty string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200559@lists.php.net to get a copy of this message
From: iivarih at gmail dot com Operating system: Debian Jessie PHP version: 7.0.5 Package: PostgreSQL related Bug Type: Bug Bug description:pg_query_params(): NULL converts to empty string Description: ------------ pg_query_params(): NULL converts to empty string, but only after looping over the params array with a reference. php version: 7.0.5-1~dotdeb+8.1 tested against postgres 9.5 Test script: --------------- $sql = "INSERT INTO params_test (value, details) VALUES ($1, $2)"; $params = array(null, "insert before looping with a reference"); $result = pg_query_params($this->connection, $sql, $params); $params2 = array(null, "insert after looping with a reference"); foreach ($params2 as &$p) { // doing nothing } unset($p); $result = pg_query_params($this->connection, $sql, $params2); Expected result: ---------------- I would expect that both calls to pg_query_params() would insert SQL NULL as 'value'. Actual result: -------------- The first call to pg_query_params() inserts SQL NULL as expected: 2016-04-15 11:59:07 EEST LOG: execute <unnamed>: INSERT INTO params_test (value, details) VALUES ($1, $2) 2016-04-15 11:59:07 EEST DETAIL: parameters: $1 = NULL, $2 = 'insert before looping with a reference' The second call inserts empty string as 'value' which is unexpected: 2016-04-15 11:59:07 EEST LOG: execute <unnamed>: INSERT INTO params_test (value, details) VALUES ($1, $2) 2016-04-15 11:59:07 EEST DETAIL: parameters: $1 = '', $2 = 'insert after looping with a reference' -- Edit bug report at https://bugs.php.net/bug.php?id=72028&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72028&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72028&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72028&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72028&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72028&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72028&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72028&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72028&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72028&r=support Expected behavior: https://bugs.php.net/fix.php?id=72028&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72028&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72028&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72028&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72028&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72028&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72028&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72028&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72028&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72028&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72028&r=mysqlcfg

« previous php.bugs (#200559) next »