summaryrefslogtreecommitdiffstats
path: root/15dc0f40438599f20303dbcec77bce010af88270.patch
blob: e200ba4c4c39d8777028aba1bbff06f79f2be43a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 15dc0f40438599f20303dbcec77bce010af88270 Mon Sep 17 00:00:00 2001
From: Bo Yang <teboring@google.com>
Date: Sun, 1 Dec 2019 16:43:29 +0000
Subject: [PATCH] Make c extension portable for php 7.4

---
 php/ext/google/protobuf/protobuf.h | 19 +++++++-------
 php/ext/google/protobuf/storage.c  |  4 ++-
 tests.sh                           | 42 ++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index 059ee55fa1..ee3620def5 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -410,15 +410,14 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
   zend_object std;                \
   };
 
-#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME)   \
-  void LOWWERNAME##_init(TSRMLS_D) {                                         \
-    zend_class_entry class_type;                                             \
-    const char* class_name = CLASSNAME;                                      \
-    INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME),            \
-                        LOWWERNAME##_methods);                               \
-    LOWWERNAME##_type = zend_register_internal_class_ex(                     \
-        &class_type, message_type TSRMLS_CC);                                \
-    zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC);
+#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
+  void LOWWERNAME##_init(TSRMLS_D) {                                       \
+    zend_class_entry class_type;                                           \
+    const char* class_name = CLASSNAME;                                    \
+    INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME),          \
+                        LOWWERNAME##_methods);                             \
+    LOWWERNAME##_type = zend_register_internal_class(&class_type);         \
+    zend_do_inheritance(LOWWERNAME##_type, message_type);
 #define PHP_PROTO_INIT_SUBMSGCLASS_END \
   }
 
@@ -428,7 +427,7 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
     const char* class_name = CLASSNAME;                                      \
     INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME),            \
                         LOWWERNAME##_methods);                               \
-    LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC);
+    LOWWERNAME##_type = zend_register_internal_class(&class_type);
 #define PHP_PROTO_INIT_ENUMCLASS_END \
   }
 
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index 235c5df8a8..f96dfd0e09 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -100,8 +100,10 @@ bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
       if (EXPECTED(cached_zval != NULL)) {
 #if PHP_MAJOR_VERSION < 7
         REPLACE_ZVAL_VALUE((zval**)memory, value, 1);
-#else
+#elif PHP_VERSION_ID < 70400
         zend_assign_to_variable(cached_zval, value, IS_CV);
+#else
+        zend_assign_to_variable(cached_zval, value, IS_CV, 0);
 #endif
       }
       break;