Skip to content

Commit baf125c

Browse files
authored
Fix build on PHP 8.5 (#14)
1 parent e4d0d8e commit baf125c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

oci_statement.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
} \
4848
} while(0)
4949

50-
static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob);
50+
static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob);
5151

5252
#define OCI_TEMPLOB_CLOSE(envhp, svchp, errhp, lob) \
5353
do \
@@ -98,10 +98,13 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
9898
S->einfo.errmsg = NULL;
9999
}
100100

101-
/* TODO: There's php_pdo_stmt_valid_db_obj_handle in PHP-8.5-dev that does these checks. */
101+
#if PHP_API_VERSION < 20240925
102102
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
103103
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
104104
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
105+
#else
106+
bool server_obj_usable = php_pdo_stmt_valid_db_obj_handle(stmt);
107+
#endif
105108

106109
if (S->cols) {
107110
for (i = 0; i < stmt->column_count; i++) {
@@ -393,7 +396,7 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
393396
* wanted to bind a lob locator into it from the query
394397
* */
395398

396-
stm = oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)P->thing);
399+
stm = oci_create_lob_stream(stmt, (OCILobLocator*)P->thing);
397400
if (stm) {
398401
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE);
399402
php_stream_to_zval(stm, parameter);
@@ -711,12 +714,16 @@ static const php_stream_ops oci_blob_stream_ops = {
711714
NULL
712715
};
713716

714-
static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob)
717+
static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
715718
{
716719
php_stream *stm;
717720
struct oci_lob_self *self = ecalloc(1, sizeof(*self));
718721

719-
ZVAL_COPY_VALUE(&self->dbh, dbh);
722+
#if PHP_API_VERSION < 20240925
723+
ZVAL_COPY_VALUE(&self->dbh, &stmt->database_object_handle);
724+
#else
725+
ZVAL_OBJ(&self->dbh, stmt->database_object_handle);
726+
#endif
720727
self->lob = lob;
721728
self->offset = 1; /* 1-based */
722729
self->stmt = stmt;
@@ -756,7 +763,7 @@ static int oci_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo_
756763

757764
if (C->dtype == SQLT_BLOB || C->dtype == SQLT_CLOB) {
758765
if (C->data) {
759-
php_stream *stream = oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)C->data);
766+
php_stream *stream = oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
760767
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
761768
php_stream_to_zval(stream, result);
762769
return 1;

0 commit comments

Comments
 (0)