projects/aports·blob master · refs

53 lines · 1.9 KiB

1Patch-Source: https://github.com/msgpack/msgpack-php/pull/185
2--
3From cf19b26b6be9b7b5af10fe469fdcd661615d1acb Mon Sep 17 00:00:00 2001
4From: Andy Postnikov <[email protected]>
5Date: Wed, 12 Aug 2026 03:50:44 +0200
6Subject: [PATCH] fix build with PHP 8.6: unserialize_callback_func is a
7 zend_string
8
9php-src commit c82acefe470 converted the PG(unserialize_callback_func)
10global from char* to zend_string*, so msgpack_unserialize_class() no
11longer compiles against PHP 8.6.
12
13Mirror what ext/standard/var_unserializer.re does in 8.6: an empty ini
14value is a non-NULL zero-length string and must still be treated as no
15callback, and the name is duplicated rather than refcounted since the
16ini string may be persistent.
17---
18 msgpack_unpack.c | 10 ++++++++++
19 1 file changed, 10 insertions(+)
20
21diff --git a/msgpack_unpack.c b/msgpack_unpack.c
22index 88387e5..07275a9 100644
23--- a/msgpack_unpack.c
24+++ b/msgpack_unpack.c
25@@ -276,15 +276,25 @@ static zend_class_entry* msgpack_unserialize_class(zval **container, zend_string
26 }
27
28 /* Check for unserialize callback */
29+#if PHP_VERSION_ID >= 80600
30+ /* php 8.6 turned the unserialize_callback_func global into a zend_string* */
31+ if ((PG(unserialize_callback_func) == NULL) ||
32+ (ZSTR_LEN(PG(unserialize_callback_func)) == 0)) {
33+#else
34 if ((PG(unserialize_callback_func) == NULL) ||
35 (PG(unserialize_callback_func)[0] == '\0')) {
36+#endif
37 incomplete_class = 1;
38 ce = PHP_IC_ENTRY;
39 break;
40 }
41
42 /* Call unserialize callback */
43+#if PHP_VERSION_ID >= 80600
44+ ZVAL_STR(&user_func, zend_string_dup(PG(unserialize_callback_func), false));
45+#else
46 ZVAL_STRING(&user_func, PG(unserialize_callback_func));
47+#endif
48 ZVAL_STR(&args[0], class_name);
49
50 func_call_status = call_user_function(CG(function_table), NULL, &user_func, &retval, 1, args);
51--
522.53.0
53