From 0ae46af2fc52a860cbc68222745b900b5dc5459b Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 20 Oct 2025 00:10:40 +0200 Subject: [PATCH] Zend: remove zval_dtor() compatibility macro This is an alias for zval_ptr_dtor_nogc(). I've seen people make mistakes against this and use zval_dtor() instead of zval_ptr_dtor(). The crucial detail here is that the former won't root possible GC cycles while the latter will. We can avoid the confusion by just retiring this compatibility macro. --- UPGRADING.INTERNALS | 2 ++ Zend/zend_variables.h | 3 --- ext/pdo/pdo_stmt.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index fe2781e025687..5af1a190e3958 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -29,6 +29,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES . CHECK_ZVAL_NULL_PATH() and CHECK_NULL_PATH() have been removed, use zend_str_has_nul_byte(Z_STR_P(...)) and zend_char_has_nul_byte() respectively. + . The zval_dtor() alias of zval_ptr_dtor_nogc() has been removed. + Call zval_ptr_dtor_nogc() directly instead. ======================== 2. Build system changes diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h index 1cb745ca1b1dc..d90ad9951782a 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -81,9 +81,6 @@ ZEND_API void zval_ptr_dtor(zval *zval_ptr); ZEND_API void zval_ptr_safe_dtor(zval *zval_ptr); ZEND_API void zval_internal_ptr_dtor(zval *zvalue); -/* Kept for compatibility */ -#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue) - ZEND_API void zval_add_ref(zval *p); END_EXTERN_C() diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index e2723c703f0ac..e87af66c75868 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1052,7 +1052,7 @@ PHP_METHOD(PDOStatement, fetch) array_init_size(return_value, 1); bool success = pdo_do_key_pair_fetch(stmt, ori, off, Z_ARRVAL_P(return_value)); if (!success) { - zval_dtor(return_value); + zval_ptr_dtor_nogc(return_value); PDO_HANDLE_STMT_ERR(); RETURN_FALSE; }