Simple successful insert example, to show that all columns get overwritten:
https://github.com/pdgcvs/DoctrineInsertPHP7
When trying to use persist method with OCI8 driver on PHP 7 all the column values got overwritten by one.
This also leads to many format validation errors preventing the data from being inserted into table.
The problem seems to be on OCI8Statement->bindValue function when the local variable $value is passed as reference to bindParam.
I tried to make a simple fix by storing values of bind call in an array (instance member) before passing it as reference to bindParam.
So far it seems to be working.
https://github.com/pdgcvs/dbal/commit/4906c6518e09d56063c6c1e9594987467071bc35
This fix solved the problem that I was having with doctrine+oci8 on php7. Thanks my friend!
@pdgcvs is that actually the "new" expected behaviour of OCI8 on PHP7 or rather a bug in PHP7? We should try to avoid fixing PHP bugs in userland where possible. If it is a PHP bug, we could still fix that in DBAL as a workaround, but should then try to get that fixed in PHP itself in the long term.
@deeky666 and if this bug was in earlier versions of php 7? The simple way that is fixed, if it's a bug of php 7, the code yet will keep running. Good that's now working on php 7.
@deeky666 and if this bug was in earlier versions of php 7?
That's why they're called "patch releases": you'd simply upgrade
I'll leave this issue open for reference until it is fixed in the driver. See PHP ticket. Let's see what's happening at PHP side before taking any action in Doctrine.
In PHP ticket:
[2016-02-22 04:41 UTC] [email protected]
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."
So there's been no movement on this in a while, is anyone going to evaluate and or comment on the pull request?
Handled in https://github.com/doctrine/dbal/pull/2434
FWIW there is a proposed OCI8 patch in https://bugs.php.net/patch-display.php?bug_id=71148&patch=oci8-php7-bind&revision=latest
Most helpful comment
So there's been no movement on this in a while, is anyone going to evaluate and or comment on the pull request?