Skip to content

Commit 780b0b4

Browse files
committed
more fix for PHP 8
1 parent e3ef201 commit 780b0b4

5 files changed

Lines changed: 24 additions & 13 deletions

File tree

msgpack_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static ZEND_METHOD(msgpack, unpacker) /* {{{ */ {
274274
ZVAL_STRING(&func_name, "__construct");
275275

276276
object_init_ex(return_value, msgpack_unpacker_ce);
277-
call_user_function_ex(CG(function_table), return_value, &func_name, &construct_return, 1, args, 0, NULL);
277+
call_user_function(CG(function_table), return_value, &func_name, &construct_return, 1, args);
278278

279279
zval_ptr_dtor(&func_name);
280280
}

msgpack_convert.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static inline int msgpack_convert_long_to_properties(HashTable *ht, zval *object
3636

3737
if (msgpack_convert_array(&tplval, data, dataval) == SUCCESS) {
3838
zend_hash_move_forward_ex(props, prop_pos);
39-
zend_update_property(Z_OBJCE_P(object), object, prop_name, prop_len, &tplval);
39+
zend_update_property(Z_OBJCE_P(object), OBJ_FOR_PROP(object), prop_name, prop_len, &tplval);
4040
return SUCCESS;
4141
}
4242
return FAILURE;
@@ -45,14 +45,14 @@ static inline int msgpack_convert_long_to_properties(HashTable *ht, zval *object
4545
{
4646
if (msgpack_convert_object(&tplval, data, val) == SUCCESS) {
4747
zend_hash_move_forward_ex(props, prop_pos);
48-
zend_update_property(Z_OBJCE_P(object), object, prop_name, prop_len, &tplval);
48+
zend_update_property(Z_OBJCE_P(object), OBJ_FOR_PROP(object), prop_name, prop_len, &tplval);
4949
return SUCCESS;
5050
}
5151
return FAILURE;
5252
}
5353
default:
5454
zend_hash_move_forward_ex(props, prop_pos);
55-
zend_update_property(Z_OBJCE_P(object), object, prop_name, prop_len, val);
55+
zend_update_property(Z_OBJCE_P(object), OBJ_FOR_PROP(object), prop_name, prop_len, val);
5656
return SUCCESS;
5757
}
5858
}
@@ -89,10 +89,10 @@ static inline int msgpack_convert_string_to_properties(zval *object, zend_string
8989
prot_name = zend_mangle_property_name("*", 1, ZSTR_VAL(key), ZSTR_LEN(key), 1);
9090

9191
if (zend_hash_find(propers, priv_name) != NULL) {
92-
zend_update_property_ex(ce, object, key, val);
92+
zend_update_property_ex(ce, OBJ_FOR_PROP(object), key, val);
9393
return_code = SUCCESS;
9494
} else if (zend_hash_find(propers, prot_name) != NULL) {
95-
zend_update_property_ex(ce, object, key, val);
95+
zend_update_property_ex(ce, OBJ_FOR_PROP(object), key, val);
9696
return_code = SUCCESS;
9797
} else {
9898
#if PHP_VERSION_ID < 80000
@@ -310,8 +310,9 @@ int msgpack_convert_object(zval *return_value, zval *tpl, zval *value) /* {{{ */
310310
fci.retval = &retval;
311311
fci.param_count = 0;
312312
fci.params = &params;
313+
#if PHP_VERSION_ID < 80000
313314
fci.no_separation = 1;
314-
315+
#endif
315316
#if PHP_VERSION_ID < 70300
316317
fcc.initialized = 1;
317318
#endif
@@ -434,10 +435,10 @@ int msgpack_convert_object(zval *return_value, zval *tpl, zval *value) /* {{{ */
434435
return FAILURE;
435436
}
436437

437-
zend_update_property_ex(ce, return_value, str_key, &nv);
438+
zend_update_property_ex(ce, OBJ_FOR_PROP(return_value), str_key, &nv);
438439
zval_ptr_dtor(&nv);
439440
} else {
440-
zend_update_property(ce, return_value, prop_name, prop_len, aryval);
441+
zend_update_property(ce, OBJ_FOR_PROP(return_value), prop_name, prop_len, aryval);
441442
}
442443
num_key++;
443444
} ZEND_HASH_FOREACH_END();

msgpack_pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static inline void msgpack_serialize_array(smart_str *buf, zval *val, HashTable
223223
if (object) {
224224
#if PHP_VERSION_ID >= 70400
225225
if (Z_OBJ_HANDLER_P(val, get_properties_for)) {
226-
ht = Z_OBJ_HANDLER_P(val, get_properties_for)(val, ZEND_PROP_PURPOSE_ARRAY_CAST);
226+
ht = Z_OBJ_HANDLER_P(val, get_properties_for)(OBJ_FOR_PROP(val), ZEND_PROP_PURPOSE_ARRAY_CAST);
227227
free_ht = 1;
228228
} else {
229229
ht = Z_OBJPROP_P(val);
@@ -409,7 +409,7 @@ static inline void msgpack_serialize_object(smart_str *buf, zval *val, HashTable
409409

410410
if (ce && ce != PHP_IC_ENTRY &&
411411
zend_hash_exists(&ce->function_table, sleep_zstring)) {
412-
if ((res = call_user_function_ex(CG(function_table), val_noref, &fname, &retval, 0, 0, 1, NULL)) == SUCCESS) {
412+
if ((res = call_user_function(CG(function_table), val_noref, &fname, &retval, 0, 0)) == SUCCESS) {
413413

414414
if (EG(exception)) {
415415
zval_ptr_dtor(&retval);

msgpack_unpack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static zend_class_entry* msgpack_unserialize_class(zval **container, zend_string
282282
ZVAL_STRING(&user_func, PG(unserialize_callback_func));
283283
ZVAL_STR(&args[0], class_name);
284284

285-
func_call_status = call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL);
285+
func_call_status = call_user_function(CG(function_table), NULL, &user_func, &retval, 1, args);
286286
zval_ptr_dtor(&user_func);
287287
if (func_call_status != SUCCESS) {
288288
MSGPACK_WARNING("[msgpack] (%s) defined (%s) but not found",
@@ -329,7 +329,11 @@ static zend_class_entry* msgpack_unserialize_class(zval **container, zend_string
329329

330330
/* store incomplete class name */
331331
if (incomplete_class) {
332+
#if PHP_VERSION_ID < 80000
332333
php_store_class_name(container_val, ZSTR_VAL(class_name), ZSTR_LEN(class_name));
334+
#else
335+
php_store_class_name(container_val, class_name);
336+
#endif
333337
}
334338

335339
return ce;
@@ -836,7 +840,7 @@ int msgpack_unserialize_map_item(msgpack_unserialize_data *unpack, zval **contai
836840
zend_hash_str_exists(&Z_OBJCE_P(container_val)->function_table, "__wakeup", sizeof("__wakeup") - 1)) {
837841
zval wakeup, r;
838842
ZVAL_STRING(&wakeup, "__wakeup");
839-
call_user_function_ex(CG(function_table), container_val, &wakeup, &r, 0, NULL, 1, NULL);
843+
call_user_function(CG(function_table), container_val, &wakeup, &r, 0, NULL);
840844
zval_ptr_dtor(&r);
841845
zval_ptr_dtor(&wakeup);
842846
}

php_msgpack.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ PHP_MSGPACK_API int php_msgpack_unserialize(
5252
# define MSGPACK_ENDIAN_BIG_BYTE 0
5353
#endif
5454

55+
#if PHP_VERSION_ID < 80000
56+
# define OBJ_FOR_PROP(zv) (zv)
57+
#else
58+
# define OBJ_FOR_PROP(zv) Z_OBJ_P(zv)
59+
#endif
60+
5561
#endif /* PHP_MSGPACK_H */

0 commit comments

Comments
 (0)