Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions Zend/tests/weakrefs/gh20073.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GH-20073 (Assertion failure in WeakMap offset operations on reference)
--FILE--
<?php
$obj = new stdClass;
$map = new WeakMap;
$integer = 1;
$map[$obj] = 0;
$map[$obj] =& $integer;
$integer++;
var_dump($map[$obj], $map->offsetGet($obj));
?>
--EXPECT--
int(2)
int(2)
2 changes: 1 addition & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -12062,7 +12062,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)))) {
Expand Down
14 changes: 7 additions & 7 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions Zend/zend_operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ ZEND_METHOD(WeakMap, offsetGet)
RETURN_THROWS();
}

ZVAL_COPY(return_value, zv);
RETURN_COPY_DEREF(zv);
}

ZEND_METHOD(WeakMap, offsetSet)
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/mysqli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_odbc/odbc_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
4 changes: 2 additions & 2 deletions ext/sockets/multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/head.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/http_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions main/streams/userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down