Bug #71947 [Com]: Bizarre behavior oci8 with call_user_func_array

From: Date: Tue, 12 Apr 2016 02:50:38 +0000
Subject: Bug #71947 [Com]: Bizarre behavior oci8 with call_user_func_array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200500@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71947&edit=1

 ID:                 71947
 Comment by:         sergei dot solomonov at gmail dot com
 Reported by:        sergei dot solomonov at gmail dot com
 Summary:            Bizarre behavior oci8 with call_user_func_array
 Status:             Open
 Type:               Bug
 Package:            OCI8 related
 Operating System:   Ubuntu 15.04
 PHP Version:        7.0.4
 Block user comment: N
 Private report:     N

 New Comment:

2sixd, yes that works. Like I said, some slight changes may result to different output. Now I'm
trying to identify this bug with php 7.0.5. This behaviour were changed, but still buggy.


Previous Comments:
------------------------------------------------------------------------
[2016-04-12 02:24:13] sixd@php.net

You need to make sure the memory address being bound is still available at time of OCI8 execute.
However ref counting in PHP core changed a lot in PHP 7 as part of the performance work and the ref
count of $v in bindVal() is different from that in PHP 5.6.

This works in PHP 7:
$v = 'expected value';
(new dbTest)->bindVal([&$v])
->execute()
->result();

------------------------------------------------------------------------
[2016-04-01 17:31:31] sergei dot solomonov at gmail dot com

Sorry wrong php version in description, it tested with 7.0.4

------------------------------------------------------------------------
[2016-04-01 17:22:07] sergei dot solomonov at gmail dot com

Description:
------------
Os info: Ubuntu 15.04, Linux 4.2.0-19-generic
Php version: 7.0.5
Configure command: 	'./configure' '--enable-zip' '--enable-intl'
'--with-oci8' '--disable-cgi'
'--with-apxs2=/usr/local/apache/bin/apxs' '--enable-opcache'
'--enable-sigchild' '--enable-mbstring' '--with-xsl'
'--with-gd' '--with-config-file-scan-dir=/usr/local/apache/conf'
'--with-openssl' '--with-curl' '--with-zlib'
'--enable-timezonedb'
Php ini: php.ini-production, no changes

I'm in migrating process from php 5.6.9 to 7.0.5. I noticed very strange errors with oci8 +
call_user_func_array functions. Test script shows how to get other bind value rather then you were
supplied as a parameter. If you'll try to do some little changes you may have different
results. Also I had a segfaults, but now I can't reproduce it. 

Test script:
---------------
class dbTest
{
    private $stmt;
    public function __construct()
    {
        $conn = oci_connect('user', 'password', 'dbmane');
        $this->stmt = oci_parse($conn, 'select :bindValue as result from dual');
    }
    public function runOciFunc($funcName, array $funcArgs)
    {
        call_user_func_array("oci_$funcName", $funcArgs);
    }
    public function bindVal(array $bind)
    {
        foreach ($bind as $k => $v) {
            $this->runOciFunc('bind_by_name', [$this->stmt, ':bindValue',
&$v]);
        }
        return $this;
    }
    public function execute()
    {
        $this->runOciFunc('execute', [$this->stmt]);
        return $this;
    }
    public function result()
    {
        var_dump(oci_fetch_assoc($this->stmt));
    }
}
(new dbTest)->bindVal(['expected value'])
            ->execute()
            ->result();

Expected result:
----------------
array(1) { ["RESULT"]=> string(14) "expected value" }

Actual result:
--------------
array(1) { ["RESULT"]=> string(11) "oci_execute" }


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71947&edit=1


Thread (5 messages)

« previous php.bugs (#200500) next »