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
Status: Closed Package: OCI8 related
PHP Version: 7.0.0 OS: Linux
Private report: No CVE-ID:
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 - 22 = ?
Subscribe to this entry?

 
 [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)

Add a Patch

Pull Requests

Add a Pull Request

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-2017 The PHP Group
All rights reserved.
Last updated: Sun Jun 25 13:01:39 2017 UTC