Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCI8 - bindValue overwrite previous values #2261

Closed
pdgcvs opened this issue Dec 15, 2015 · 10 comments
Closed

OCI8 - bindValue overwrite previous values #2261

pdgcvs opened this issue Dec 15, 2015 · 10 comments
Assignees
Milestone

Comments

@pdgcvs
Copy link

pdgcvs commented Dec 15, 2015

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

@arcostasi
Copy link

This fix solved the problem that I was having with doctrine+oci8 on php7. Thanks my friend!

@deeky666
Copy link
Member

@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.

@arcostasi
Copy link

@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.

@Ocramius
Copy link
Member

@deeky666 and if this bug was in earlier versions of php 7?

That's why they're called "patch releases": you'd simply upgrade

@deeky666
Copy link
Member

deeky666 commented Jan 6, 2016

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.

@eisberg
Copy link
Contributor

eisberg commented Feb 26, 2016

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."

@mmucklo
Copy link
Contributor

mmucklo commented Apr 12, 2016

So there's been no movement on this in a while, is anyone going to evaluate and or comment on the pull request?

deeky666 added a commit to deeky666/dbal that referenced this issue Jun 30, 2016
deeky666 added a commit to deeky666/dbal that referenced this issue Jun 30, 2016
deeky666 added a commit to deeky666/dbal that referenced this issue Jul 7, 2016
deeky666 added a commit to deeky666/dbal that referenced this issue Jul 7, 2016
Ocramius pushed a commit that referenced this issue Jul 7, 2016
Ocramius added a commit that referenced this issue Jul 7, 2016
Ocramius added a commit that referenced this issue Jul 7, 2016
@Ocramius
Copy link
Member

Ocramius commented Jul 7, 2016

Handled in #2434

@cjbj
Copy link

cjbj commented Oct 13, 2016

FWIW there is a proposed OCI8 patch in https://bugs.php.net/patch-display.php?bug_id=71148&patch=oci8-php7-bind&revision=latest

@github-actions
Copy link

github-actions bot commented Aug 6, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants