php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71148 Bind reference overwritten on php7
Submitted: 2015-12-17 11:15 UTC Modified: 2016-10-13 03:56 UTC
From: arcostasi at gmail dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 7.0.0 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arcostasi at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-17 11:15 UTC] arcostasi at gmail dot com
Description:
------------
Simple insert on oracle database using Doctrine with OCI8 driver on PHP 7.

All the columns get overwritten by value of the last call to OCI8Statement->bindValue.

Table creation script can be found at db/ of the test script repository

The code on public/only_oci8.php reproduces the problem without Doctrine.

Test script:
---------------
https://github.com/pdgcvs/DoctrineInsertPHP7

https://github.com/pdgcvs/DoctrineInsertPHP7/blob/master/public/only_oci8.php

https://github.com/pdgcvs/DoctrineInsertPHP7/blob/master/public/only_oci8_2.php





Patches

oci8-php7-bind (last revision 2016-10-13 03:56 UTC by sixd@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 03:12 UTC] sixd@php.net
-Assigned To: +Assigned To: sixd
 [2016-01-07 11:29 UTC] deepdiver at owncloud dot com
duplicate of https://bugs.php.net/bug.php?id=70302
 [2016-02-22 04:41 UTC] sixd@php.net
-Status: Assigned +Status: Not a bug
 [2016-02-22 04:41 UTC] sixd@php.net
Looks like an expected change with PHP 7.

OCI8 needs the zval of the bound variable to be available when OCIExecute is called.
Try using pass by reference in your bindValue() function, or don't bind in a function.
This is similar to example #3 in http://php.net/manual/en/function.oci-bind-by-name.php

From the dev who analyzed this:

"Reason for this new behavior in PHP 7 is that, unlike in PHP 5.6, zval (_zend_value) in PHP 7.0 is no more have reference count field. Only its values field (zend_value) has reference count field.

Since we store the placeholder (i.e., zval variable) [not its content (zend_value)] in php_oci_bind structure, it gets overwritten when oci_bind_by_name() is called with same variable and different content in it."
 [2016-10-13 03:56 UTC] sixd@php.net
The following patch has been added/updated:

Patch Name: oci8-php7-bind
Revision:   1476330968
URL:        https://bugs.php.net/patch-display.php?bug=71148&patch=oci8-php7-bind&revision=1476330968
 [2016-10-13 03:56 UTC] sixd@php.net
-Status: Not a bug +Status: Feedback
 [2016-10-13 03:56 UTC] sixd@php.net
Frank has a suggested patch; try it and let us know whether it works for you.
 [2016-10-17 01:58 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8be59a13017f16396e862a8e50c888afafe1952d
Log: Fixed bug #71148 (Bind reference overwritten on PHP 7)
 [2016-10-17 01:58 UTC] sixd@php.net
-Status: Feedback +Status: Closed
 [2016-10-17 01:59 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8be59a13017f16396e862a8e50c888afafe1952d
Log: Fixed bug #71148 (Bind reference overwritten on PHP 7)
 [2016-10-17 02:02 UTC] sixd@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8be59a13017f16396e862a8e50c888afafe1952d
Log: Fixed bug #71148 (Bind reference overwritten on PHP 7)
 [2016-10-17 10:06 UTC] bwoebi@php.net
Automatic comment on behalf of christopher.jones@oracle.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8be59a13017f16396e862a8e50c888afafe1952d
Log: Fixed bug #71148 (Bind reference overwritten on PHP 7)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC