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

zend_list_close() returns void starting in php 8 beta3 #1184

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions source/sqlsrv/conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,13 @@ PHP_FUNCTION( sqlsrv_close )
// cause any variables still holding a reference to this to be invalid so they cause
// an error when passed to a sqlsrv function. There's nothing we can do if the
// removal fails, so we just log it and move on.
if( zend_list_close( Z_RES_P( conn_r ) ) == FAILURE ) {
LOG( SEV_ERROR, "Failed to remove connection resource %1!d!", Z_RES_HANDLE_P( conn_r ));
#if PHP_VERSION_ID < 80000
if (zend_list_close(Z_RES_P(conn_r)) == FAILURE) {
LOG(SEV_ERROR, "Failed to remove connection resource %1!d!", Z_RES_HANDLE_P(conn_r));
}
#else
zend_list_close(Z_RES_P(conn_r));
#endif

// when conn_r is first parsed in zend_parse_parameters, conn_r becomes a zval that points to a zend_resource with a refcount of 2
// need to DELREF here so the refcount becomes 1 and conn_r can be appropriate destroyed by the garbage collector when it goes out of scope
Expand Down Expand Up @@ -1265,9 +1269,14 @@ PHP_FUNCTION( sqlsrv_query )

void free_stmt_resource( _Inout_ zval* stmt_z )
{
if( FAILURE == zend_list_close( Z_RES_P( stmt_z ))) {
#if PHP_VERSION_ID < 80000
if (FAILURE == zend_list_close(Z_RES_P(stmt_z))) {
LOG(SEV_ERROR, "Failed to remove stmt resource %1!d!", Z_RES_HANDLE_P(stmt_z));
}
#else
zend_list_close(Z_RES_P(stmt_z));
#endif

ZVAL_NULL( stmt_z );
zval_ptr_dtor(stmt_z);
}
Expand Down Expand Up @@ -1317,9 +1326,13 @@ void sqlsrv_conn_close_stmts( _Inout_ ss_sqlsrv_conn* conn )

// this would call the destructor on the statement.
// There's nothing we can do if the removal fails, so we just log it and move on.
if( zend_list_close( Z_RES_P(rsrc_ptr) ) == FAILURE ) {
#if PHP_VERSION_ID < 80000
if (zend_list_close(Z_RES_P(rsrc_ptr)) == FAILURE) {
LOG(SEV_ERROR, "Failed to remove statement resource %1!d! when closing the connection", Z_RES_HANDLE_P(rsrc_ptr));
}
#else
zend_list_close(Z_RES_P(rsrc_ptr));
#endif
} ZEND_HASH_FOREACH_END();

zend_hash_destroy( conn->stmts );
Expand Down
8 changes: 6 additions & 2 deletions source/sqlsrv/stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,9 +1396,13 @@ PHP_FUNCTION( sqlsrv_free_stmt )
}

// delete the resource from Zend's master list, which will trigger the statement's destructor
if( zend_list_close( Z_RES_P(stmt_r) ) == FAILURE ) {
LOG( SEV_ERROR, "Failed to remove stmt resource %1!d!", Z_RES_P( stmt_r )->handle);
#if PHP_VERSION_ID < 80000
if (zend_list_close(Z_RES_P(stmt_r)) == FAILURE) {
LOG(SEV_ERROR, "Failed to remove stmt resource %1!d!", Z_RES_P(stmt_r)->handle);
}
#else
zend_list_close(Z_RES_P(stmt_r));
#endif

// when stmt_r is first parsed in zend_parse_parameters, stmt_r becomes a zval that points to a zend_resource with a refcount of 2
// need to DELREF here so the refcount becomes 1 and stmt_r can be appropriate destroyed by the garbage collector when it goes out of scope
Expand Down