php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71947 Bizarre behavior oci8 with call_user_func_array
Submitted: 2016-04-01 17:22 UTC Modified: 2016-08-16 06:28 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: sergei dot solomonov at gmail dot com Assigned:
Status: Duplicate Package: OCI8 related
PHP Version: 7.0.4 OS: Ubuntu 15.04
Private report: No CVE-ID: None
 [2016-04-01 17:22 UTC] 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" }

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-01 17:31 UTC] sergei dot solomonov at gmail dot com
-PHP Version: 7.0.5 +PHP Version: 7.0.4
 [2016-04-01 17:31 UTC] sergei dot solomonov at gmail dot com
Sorry wrong php version in description, it tested with 7.0.4
 [2016-04-12 02:24 UTC] 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-12 02:50 UTC] sergei dot solomonov at gmail dot com
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.
 [2016-08-16 06:28 UTC] sixd@php.net
-Status: Open +Status: Duplicate
 [2016-08-16 06:28 UTC] sixd@php.net
See bug #71148
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC