summaryrefslogtreecommitdiffstats
path: root/1251b877c4e3962c8d4d89d5a210fb380f8177ca.patch
blob: 142758dec549b1e64f539587794caffe45344355 (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
From 873bc5031c511abbcbaa17117b86d0109f0fef91 Mon Sep 17 00:00:00 2001
From: Joe Watkins <krakjoe@php.net>
Date: Thu, 6 Jun 2019 18:43:30 +0200
Subject: [PATCH] really fix incorrect usage of zend_declare_class_constant_ex,
 for PHP >=7.2

---
 kernels/ZendEngine3/main.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/kernels/ZendEngine3/main.c b/kernels/ZendEngine3/main.c
index c940e0e26..c8d45ce0b 100644
--- a/kernels/ZendEngine3/main.c
+++ b/kernels/ZendEngine3/main.c
@@ -387,7 +387,24 @@ zend_class_entry* zephir_get_internal_ce(const char *class_name, unsigned int cl
 /* Declare constants */
 int zephir_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value)
 {
-#if PHP_VERSION_ID >= 70100
+#if PHP_VERSION_ID >= 70200
+	int ret;
+	zend_string *key;
+
+	if (ce->type == ZEND_INTERNAL_CLASS) {
+		key = zend_string_init_interned(name, name_length, 1);
+	} else {
+		key = zend_string_init(name, name_length, 0);
+	}
+
+	zend_declare_class_constant_ex(ce, key, value, ZEND_ACC_PUBLIC, NULL);
+
+	if (ce->type != ZEND_INTERNAL_CLASS) {
+		zend_string_release(key);
+	}
+
+	return ret;
+#elif PHP_VERSION_ID >= 70100
 	int ret;
 
 	zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS);