From 6dc43892f042ea7be8ad79921e53a6f2f150b7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 4 Oct 2025 21:59:54 +0200 Subject: [PATCH 1/2] tree-wide: Replace `zval_is_true()` by `zend_is_true()` The former is a direct alias of the latter which is much more often used. --- Zend/zend_compile.c | 2 +- Zend/zend_operators.c | 14 +++++++------- ext/mysqli/mysqli.c | 2 +- ext/pdo/pdo_dbh.c | 2 +- ext/pdo_odbc/odbc_stmt.c | 2 +- ext/pgsql/pgsql.c | 2 +- ext/session/session.c | 6 +++--- ext/sockets/multicast.c | 4 ++-- ext/standard/head.c | 6 +++--- ext/standard/http_fopen_wrapper.c | 2 +- main/streams/userspace.c | 20 ++++++++++---------- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 480002f682e40..f6509400b2695 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -12071,7 +12071,7 @@ bool zend_try_ct_eval_cast(zval *result, uint32_t type, zval *op1) } switch (type) { case _IS_BOOL: - ZVAL_BOOL(result, zval_is_true(op1)); + ZVAL_BOOL(result, zend_is_true(op1)); return true; case IS_LONG: if (Z_TYPE_P(op1) == IS_DOUBLE && !ZEND_DOUBLE_FITS_LONG(Z_DVAL_P((op1)))) { diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 9740de7d081fd..2550fcbeb1cde 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1593,7 +1593,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, } } ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR); - op1_val = zval_is_true(op1); + op1_val = zend_is_true(op1); } } while (0); do { @@ -1613,7 +1613,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, } } ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR); - op2_val = zval_is_true(op2); + op2_val = zend_is_true(op2); } } while (0); @@ -1641,7 +1641,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) } ZEND_TRY_UNARY_OBJECT_OPERATION(ZEND_BOOL_NOT); - ZVAL_BOOL(result, !zval_is_true(op1)); + ZVAL_BOOL(result, !zend_is_true(op1)); } return SUCCESS; } @@ -2433,13 +2433,13 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ converted = true; } } else if (Z_TYPE_P(op1) < IS_TRUE) { - return zval_is_true(op2) ? -1 : 0; + return zend_is_true(op2) ? -1 : 0; } else if (Z_TYPE_P(op1) == IS_TRUE) { - return zval_is_true(op2) ? 0 : 1; + return zend_is_true(op2) ? 0 : 1; } else if (Z_TYPE_P(op2) < IS_TRUE) { - return zval_is_true(op1) ? 1 : 0; + return zend_is_true(op1) ? 1 : 0; } else if (Z_TYPE_P(op2) == IS_TRUE) { - return zval_is_true(op1) ? 0 : -1; + return zend_is_true(op1) ? 0 : -1; } else { op1 = _zendi_convert_scalar_to_number_silent(op1, &op1_copy); op2 = _zendi_convert_scalar_to_number_silent(op2, &op2_copy); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index dddb53585f14e..a46b16e1d1ecd 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -316,7 +316,7 @@ static int mysqli_object_has_property(zend_object *object, zend_string *name, in zval rv; zval *value = mysqli_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { - has_property = zval_is_true(value); + has_property = zend_is_true(value); zval_ptr_dtor(value); } break; diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index b34653e286728..2eaa3940f82e5 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -805,7 +805,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value) *bval = false; return true; case IS_LONG: - *bval = zval_is_true(value); + *bval = zend_is_true(value); return true; case IS_STRING: /* TODO Should string be allowed? */ default: diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 8e27d27173c0b..171fb7b7b1e95 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -803,7 +803,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, zend_long attr, zval *val) return 0; case PDO_ODBC_ATTR_ASSUME_UTF8: - S->assume_utf8 = zval_is_true(val); + S->assume_utf8 = zend_is_true(val); return 0; default: strcpy(S->einfo.last_err_msg, "Unknown Attribute"); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index feea2ed60e6f4..dbb875e88f190 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -4967,7 +4967,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string * break; /* break out for() */ } - if (zval_is_true(is_enum)) { + if (zend_is_true(is_enum)) { /* enums need to be treated like strings */ data_type = PG_TEXT; } else { diff --git a/ext/session/session.c b/ext/session/session.c index 1c01201a55bc5..8796005e9232f 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1858,15 +1858,15 @@ PHP_FUNCTION(session_set_cookie_params) domain = zval_get_string(value); found++; } else if (zend_string_equals_literal_ci(key, "secure")) { - secure = zval_is_true(value); + secure = zend_is_true(value); secure_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "partitioned")) { - partitioned = zval_is_true(value); + partitioned = zend_is_true(value); partitioned_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "httponly")) { - httponly = zval_is_true(value); + httponly = zend_is_true(value); httponly_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "samesite")) { diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index f331fd177ebfd..522e6b346f66d 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -293,7 +293,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock, goto dosockopt; case IP_MULTICAST_LOOP: - ipv4_mcast_ttl_lback = (unsigned char) zval_is_true(arg4); + ipv4_mcast_ttl_lback = (unsigned char) zend_is_true(arg4); goto ipv4_loop_ttl; case IP_MULTICAST_TTL: @@ -357,7 +357,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, goto dosockopt; case IPV6_MULTICAST_LOOP: - ov = (int) zval_is_true(arg4); + ov = (int) zend_is_true(arg4); goto ipv6_loop_hops; case IPV6_MULTICAST_HOPS: convert_to_long(arg4); diff --git a/ext/standard/head.c b/ext/standard/head.c index 087ba6a34806c..76ba89dc01713 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -213,13 +213,13 @@ static zend_result php_head_parse_cookie_options_array(HashTable *options, zend_ } else if (zend_string_equals_literal_ci(key, "domain")) { *domain = zval_get_string(value); } else if (zend_string_equals_literal_ci(key, "secure")) { - *secure = zval_is_true(value); + *secure = zend_is_true(value); } else if (zend_string_equals_literal_ci(key, "httponly")) { - *httponly = zval_is_true(value); + *httponly = zend_is_true(value); } else if (zend_string_equals_literal_ci(key, "samesite")) { *samesite = zval_get_string(value); } else if (zend_string_equals_literal_ci(key, "partitioned")) { - *partitioned = zval_is_true(value); + *partitioned = zend_is_true(value); } else { zend_value_error("%s(): option \"%s\" is invalid", get_active_function_name(), ZSTR_VAL(key)); return FAILURE; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index b7087befcb271..da150381f43f3 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -276,7 +276,7 @@ static zend_string *php_stream_http_response_headers_parse(php_stream_wrapper *w if (!strncasecmp(last_header_line, "Location:", sizeof("Location:")-1)) { /* Check if the location should be followed. */ if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) { - header_info->follow_location = zval_is_true(tmpzval); + header_info->follow_location = zend_is_true(tmpzval); } else if (!((response_code >= 300 && response_code < 304) || 307 == response_code || 308 == response_code)) { /* The redirection should not be automatic if follow_location is not set and diff --git a/main/streams/userspace.c b/main/streams/userspace.c index deae2ff5d2d3c..b1ea8818aeccd 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -346,7 +346,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * zval_ptr_dtor(&args[3]); goto end; } - if (zval_is_true(&zretval)) { + if (zend_is_true(&zretval)) { /* the stream is now open! */ stream = php_stream_alloc_rel(&php_stream_userspace_ops, us, 0, mode); @@ -430,7 +430,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char goto end; } - if (zval_is_true(&zretval)) { + if (zend_is_true(&zretval)) { /* the stream is now open! */ stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode); @@ -672,7 +672,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count goto err; } - if (zval_is_true(&retval)) { + if (zend_is_true(&retval)) { stream->eof = 1; } zval_ptr_dtor(&retval); @@ -720,7 +720,7 @@ static int php_userstreamop_flush(php_stream *stream) zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &retval, 0, NULL); zend_string_release_ex(func_name, false); - int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval) ? 0 : -1; + int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval) ? 0 : -1; zval_ptr_dtor(&retval); @@ -755,7 +755,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when ret = -1; goto out; - } else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) { + } else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval)) { ret = 0; } else { ret = -1; @@ -1090,7 +1090,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1128,7 +1128,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1166,7 +1166,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1203,7 +1203,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1265,7 +1265,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); From ed6457bc39b77fcd1d6e10c308d1724e6c8e85d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 4 Oct 2025 22:19:04 +0200 Subject: [PATCH 2/2] zend_operators: Remove `zval_is_true()` --- UPGRADING.INTERNALS | 2 ++ Zend/zend_operators.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index c2ec44e1e0c2a..ada814964fc5f 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -20,6 +20,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES . The misnamed ZVAL_IS_NULL() has been removed. Use Z_ISNULL() instead. . New zend_class_entry.ce_flags2 and zend_function.fn_flags2 fields were added, given the primary flags were running out of bits. + . The zval_is_true() alias of zend_is_true() has been removed. Call + zend_is_true() directly instead. ======================== 2. Build system changes diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index a3bf19fca8f27..4a74e6ebaefe9 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -404,9 +404,6 @@ static zend_always_inline bool try_convert_to_string(zval *op) { ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op); ZEND_API bool ZEND_FASTCALL zend_object_is_true(const zval *op); -#define zval_is_true(op) \ - zend_is_true(op) - static zend_always_inline bool i_zend_is_true(const zval *op) { bool result = 0;