Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed PHP 8.5 compilation error
  • Loading branch information
naizhao committed Jul 6, 2025
commit 7f02c3d892dfd8b5338dbc652e06c2679efdc433
12 changes: 12 additions & 0 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,24 @@ static zend_internal_arg_info *copy_arginfo(const zend_function *zf, zend_intern
memcpy(new_list, old_list, ZEND_TYPE_LIST_SIZE(old_list->num_types));
ZEND_TYPE_SET_PTR(new_arg_info[i].type, new_list);

#if PHP_VERSION_ID >= 80500
// For PHP 8.5+, ZEND_TYPE_LIST_FOREACH gives a const pointer, which we can't modify.
// We must use a manual loop over the list we allocated ourselves.
for (uint32_t j = 0; j < new_list->num_types; j++) {
zend_type *list_type = &new_list->types[j];
if (ZEND_TYPE_HAS_NAME(*list_type)) {
zend_string *name = zend_string_dup(ZEND_TYPE_NAME(*list_type), 1);
ZEND_TYPE_SET_PTR(*list_type, name);
}
}
#else
zend_type *list_type;
ZEND_TYPE_LIST_FOREACH(new_list, list_type) {
zend_string *name = zend_string_dup(ZEND_TYPE_NAME(*list_type), true);
ZEND_TYPE_SET_PTR(*list_type, name);
}
ZEND_TYPE_LIST_FOREACH_END();
#endif
} else if (ZEND_TYPE_HAS_NAME(arg_info[i].type)) {
zend_string *name = zend_string_dup(ZEND_TYPE_NAME(arg_info[i].type), true);
ZEND_TYPE_SET_PTR(new_arg_info[i].type, name);
Expand Down
6 changes: 5 additions & 1 deletion thirdparty/php/main/SAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ static void swoole_php_treat_data(int arg, char *str, zval *destArray) {

switch (arg) {
case PARSE_STRING:
separator = PG(arg_separator).input;
#if PHP_VERSION_ID >= 80500
separator = ZSTR_VAL(PG(arg_separator).input);
#else
separator = PG(arg_separator).input;
#endif
break;
case PARSE_COOKIE:
separator = (char *) ";\0";
Expand Down