Edit report at https://bugs.php.net/bug.php?id=73002&edit=1
ID: 73002
Comment by: dave dot reddy at enbridge dot com
Reported by: lzsiga at freemail dot c3 dot hu
Summary: bigendian64/php7/oci8: output bind-variables doesn't
work
Status: Open
Type: Bug
Package: OCI8 related
Operating System: 64-bit / BigEndian
PHP Version: 7.*
Block user comment: N
Private report: N
New Comment:
Although this fixes the binding of numeric values, binding of boolean variable is still broken with
this fix.
Previous Comments:
------------------------------------------------------------------------
[2018-02-13 20:17:18] dave dot reddy at enbridge dot com
This patch appears to have fixed the issue for us as well. AIX 7.1, 64bit, PHP 7.2.1, running
fast-cgi daemons.
------------------------------------------------------------------------
[2017-12-04 09:53:59] lzsiga at freemail dot c3 dot hu
Latest patch works with PHP-7.2.0 too.
Also I created a little graph to illustrate the problem (i.e. the difference between big-endian and
little-endian, when it comes to mixing 32-bit and 64-bit)
0x1234 in eight byte
little endian
+----+----+----+----+----+----+----+----+
| 34 , 12 ; 00 , 00 | 00 , 00 ; 00 , 00 |
+----+----+----+----+----+----+----+----+
interpreted as int32: 0x00001234
<------------------>
interpreted as int64: 0x0000000000001234
<--------------------------------------->
big endian
+----+----+----+----+----+----+----+----+
| 00 , 00 ; 00 , 00 | 00 , 00 ; 12 , 34 |
+----+----+----+----+----+----+----+----+
interpreted as int32: 0x00000000
<------------------>
interpreted as int64: 0x0000000000001234
<--------------------------------------->
big endian
+----+----+----+----+----+----+----+----+
| 00 , 00 ; 12 , 34 | 00 , 00 ; 00 , 00 |
+----+----+----+----+----+----+----+----+
interpreted as int32: 0x00001234
<------------------>
interpreted as int64: 0x0000123400000000
<--------------------------------------->
------------------------------------------------------------------------
[2017-10-29 15:09:04] lzsiga at freemail dot c3 dot hu
New patch added for 7.1.11; usage:
cd /usr/local/src/php-7.1.11; patch -p0 <oci8_statement.patch
------------------------------------------------------------------------
[2017-08-13 15:59:27] lzsiga at freemail dot c3 dot hu
The latest patch seems working on both php-7.1.7 and php-7.1.8
Here is a test-script: http://web.axelero.hu/lzsiga/oci_test.php -- I
suggest using it with php-cli.
------------------------------------------------------------------------
[2017-08-11 08:08:39] sanjayrbhabhor at gmail dot com
Found solution for power bigendian 64 bit
*** ext / oci8 / oci8_statement.c Tue Aug 1 19:36:51 2017
--- ../php-7.1.8-changed/ext/oci8/oci8_statement.c Thu Aug 10 13:25:20 2017
***************
*** 979,995 ****
}
zval_dtor (val);
ZVAL_NULL (val);
! } Else if (Z_TYPE_P (bind-> zval) == IS_STRING
! && Z_STRLEN_P (bind-> zval)> 0
! && Z_STRVAL_P (bind-> zval) [Z_STRLEN_P (bind-> zval)]! = '\ 0') {
! / * The post- PHP 5.3 feature for "interned" strings disallows
! * Their reallocation but (i) any IN binds either interned or
! * Should not already be null terminated and (ii) for OUT
! Binds, php_oci_bind_out_callback () should have allocated a
! * New string that we can modify here.
! * /
! Z_STR_P (bind-> zval) = zend_string_extend (Z_STR_P (bind-> zval), Z_STRLEN_P (bind->
zval) +1, 0);
! Z_STRVAL_P (bind-> zval) [Z_STRLEN_P (bind-> zval)] = '\ 0';
} Else if (Z_TYPE_P (bind-> zval) == IS_ARRAY) {
Int i;
Zval * entry = NULL;
--- 979,997 ----
}
zval_dtor (val);
ZVAL_NULL (val);
! } Else if (Z_TYPE_P (bind-> zval) == IS_STRING) {
! Z_STRLEN_P (bind-> zval) = bind-> dummy_len;
! If (Z_STRLEN_P (bind-> zval)> 0 &&
! Z_STRVAL_P (bind-> zval) [Z_STRLEN_P (bind-> zval)]! = '\ 0') {
! / * The post- PHP 5.3 feature for "interned" strings disallows
! * Their reallocation but (i) any IN binds either interned or
! * Should not already be null terminated and (ii) for OUT
! Binds, php_oci_bind_out_callback () should have allocated a
! * New string that we can modify here.
! * /
! Z_STR_P (bind-> zval) = zend_string_extend (Z_STR_P (bind-> zval), Z_STRLEN_P (bind->
zval) +1, 0);
! Z_STRVAL_P (bind-> zval) [Z_STRLEN_P (bind-> zval)] = '\ 0';
! }
} Else if (Z_TYPE_P (bind-> zval) == IS_ARRAY) {
Int i;
Zval * entry = NULL;
***************
*** 1371,1376 ****
--- 1373.1379 ----
* Bufpp = 0;
* Alenp = -1;
* Indpp = (dvoid *) & phpbind-> indicator;
+ Phpbind-> dummy_len = 0; / * So far, 'dummy_len' meant the maximum length; From
now, it is the actual length * /
} Else if ((phpbind-> descriptor == 0) && (phpbind-> statement == 0)) {
/ * "Normal string bind * /
convert_to_string (val);
***************
*** 1386,1391 ****
--- 1389.1395 ----
If ((phpbind-> dummy_len> 0) && (phpbind-> dummy_len <* alenp))
* Alenp = phpbind-> dummy_len;
* Indpp = (dvoid *) & phpbind-> indicator;
+ Phpbind-> dummy_len = * alenp; / * So far, 'dummy_len' meant the maximum length;
From now, it is the actual length * /
} Else if (phpbind-> statement! = 0) {
/ * RSET * /
* Bufpp = phpbind-> statement;
***************
*** 1477,1484 ****
ZVAL_STRINGL (val, NULL, Z_STRLEN (phpbind-> zval) + 1);
#endif
! / * XXX we assume that zend-zval len has 4 bytes * /
! * Alenpp = (ub4 *) & Z_STRLEN_P (phpbind-> zval);
* Bufpp = Z_STRVAL_P (phpbind-> zval);
* Piecep = OCI_ONE_PIECE;
* Rcodepp = & phpbind-> retcode;
--- 1481.1489 ----
ZVAL_STRINGL (val, NULL, Z_STRLEN (phpbind-> zval) + 1);
#endif
! / * XXX we assume that zend-zval len has 4 bytes - does not work on big endian PowerPC-64 * /
! Phpbind-> dummy_len = Z_STRLEN_P (phpbind-> zval);
! * Alenpp = & phpbind-> dummy_len;
* Bufpp = Z_STRVAL_P (phpbind-> zval);
* Piecep = OCI_ONE_PIECE;
* Rcodepp = & phpbind-> retcode;
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=73002
--
Edit this bug report at https://bugs.php.net/bug.php?id=73002&edit=1