Skip to content

Commit a96f99e

Browse files
committed
Final diff fixes for PHP7 on base platform (some mem leaks still to be fixed). Update driver name. Improve test portability (Senthil)
1 parent 4ee6a9a commit a96f99e

13 files changed

+693
-649
lines changed

ext/oci8/oci8.c

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
#error Use PHP OCI8 1.4 for your version of PHP
4343
#endif
4444

45+
/* PHP 7 is the minimum supported version for OCI8 2.1 */
46+
#if PHP_MAJOR_VERSION < 7
47+
#error Use PHP OCI8 2.0 for your version of PHP
48+
#endif
49+
4550
#include "php_oci8.h"
4651
#include "php_oci8_int.h"
4752
#include "zend_hash.h"
@@ -2629,6 +2634,8 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
26292634
void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args)
26302635
{
26312636
zval *z_statement, *array;
2637+
zval *placeholder;
2638+
/* zend_array *temp_array = (zend_array *) NULL;*/
26322639
php_oci_statement *statement; /* statement that will be fetched from */
26332640
#if (OCI_MAJOR_VERSION >= 12)
26342641
php_oci_statement *invokedstatement; /* statement this function was invoked with */
@@ -2736,53 +2743,16 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
27362743
}
27372744
#endif /* OCI_MAJOR_VERSION */
27382745

2739-
#if 0
2740-
if (expected_args > 2)
2741-
{
2742-
array_init(array);
2743-
2744-
for (i = 0; i < statement->ncolumns; i++) {
2745-
2746-
column = php_oci_statement_get_column(statement, i + 1, NULL, 0);
2747-
2748-
if (column == NULL) {
2749-
continue;
2750-
}
2751-
if ((column->indicator == -1) && ((fetch_mode & PHP_OCI_RETURN_NULLS) == 0)) {
2752-
continue;
2753-
}
2754-
2755-
if (!(column->indicator == -1)) {
2756-
zval element;
2757-
2758-
php_oci_column_to_zval(column, &element, fetch_mode);
2759-
2760-
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC)) {
2761-
add_index_zval(array, i, &element);
2762-
}
2763-
if (fetch_mode & PHP_OCI_ASSOC) {
2764-
if (fetch_mode & PHP_OCI_NUM) {
2765-
Z_TRY_ADDREF_P(&element);
2766-
}
2767-
add_assoc_zval(array, column->name, &element);
2768-
}
2769-
2770-
} else {
2771-
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC)) {
2772-
add_index_null(array, i);
2773-
}
2774-
if (fetch_mode & PHP_OCI_ASSOC) {
2775-
add_assoc_null(array, column->name);
2776-
}
2777-
}
2778-
}
2779-
2780-
/* RETURN_LONG(statement->ncolumns); */
2746+
if (expected_args > 2) {
2747+
if (Z_ISREF_P(array))
2748+
placeholder = Z_REFVAL_P(array);
2749+
else
2750+
placeholder = array;
2751+
} else {
2752+
placeholder = return_value;
27812753
}
2782-
else
2783-
#endif
2784-
{
2785-
array_init(return_value);
2754+
2755+
array_init(placeholder);
27862756

27872757
for (i = 0; i < statement->ncolumns; i++) {
27882758

@@ -2801,32 +2771,42 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
28012771
php_oci_column_to_zval(column, &element, (int) fetch_mode);
28022772

28032773
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC)) {
2804-
add_index_zval(return_value, i, &element);
2774+
add_index_zval(placeholder, i, &element);
28052775
}
28062776
if (fetch_mode & PHP_OCI_ASSOC) {
28072777
if (fetch_mode & PHP_OCI_NUM) {
28082778
Z_TRY_ADDREF_P(&element);
28092779
}
2810-
add_assoc_zval(return_value, column->name, &element);
2780+
add_assoc_zval(placeholder, column->name, &element);
28112781
}
28122782

28132783
} else {
28142784
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC)) {
2815-
add_index_null(return_value, i);
2785+
add_index_null(placeholder, i);
28162786
}
28172787
if (fetch_mode & PHP_OCI_ASSOC) {
2818-
add_assoc_null(return_value, column->name);
2788+
add_assoc_null(placeholder, column->name);
28192789
}
28202790
}
28212791
}
28222792

28232793
if (expected_args > 2) {
28242794
/* Only for ocifetchinto BC. In all other cases we return array, not long */
2825-
ZVAL_COPY(array, return_value); /* copy return_value to given reference */
2826-
/* zval_dtor(return_value); */
2795+
#if 0
2796+
zval *temp_array;
2797+
if (Z_ISREF_P(array))
2798+
temp_array = Z_REFVAL_P(array);
2799+
else /* PHP7 will pass user buffer through 'array' as reference type.
2800+
* So this part of code may not be reached. */
2801+
temp_array = array;
2802+
2803+
/* copy array content in return_value into user buffer passed through
2804+
* reference variable 'array' */
2805+
ZVAL_ARR(temp_array, Z_ARRVAL_P(return_value));
2806+
zval_ptr_dtor(return_value);
2807+
#endif
28272808
RETURN_LONG(statement->ncolumns);
28282809
}
2829-
}
28302810
}
28312811
/* }}} */
28322812

ext/oci8/package.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ only Oracle Database 9.2 client libraries are available.
5858
</stability>
5959
<license uri="http://www.php.net/license">PHP</license>
6060
<notes>
61-
PHP 7 Compatibility. This version is for PHP 7 only.
61+
This version is for PHP 7 only.
62+
Updated driver name format.
6263
</notes>
6364
<contents>
6465
<dir name="/">

ext/oci8/php_oci8_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ extern zend_class_entry *oci_coll_class_entry_ptr;
121121
* Name passed to Oracle for tracing. Note some DB views only show
122122
* the first nine characters of the driver name.
123123
*/
124-
#define PHP_OCI8_DRIVER_NAME "PHP OCI8 " PHP_OCI8_VERSION
124+
#define PHP_OCI8_DRIVER_NAME "PHP OCI8 : " PHP_OCI8_VERSION
125125

126126
/* }}} */
127127

0 commit comments

Comments
 (0)