summaryrefslogtreecommitdiffstats
path: root/5.patch
blob: 35f86766ec374893e6d750d693374f5aefe25f91 (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
66
From a0a028b2987b030153e21510ffd90a8eaf17b0ba Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 25 Aug 2021 09:28:36 +0200
Subject: [PATCH 1/2] fix for PHP 5

---
 SeasSnowflake.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/SeasSnowflake.cpp b/SeasSnowflake.cpp
index 1a3282e..06b3f5f 100755
--- a/SeasSnowflake.cpp
+++ b/SeasSnowflake.cpp
@@ -270,7 +270,11 @@ PHP_METHOD(SEASSNOWFLAKE_RES_NAME, generate)
 PHP_METHOD(SEASSNOWFLAKE_RES_NAME, degenerate)
 {
     char *id = NULL;
+#if PHP_VERSION_ID < 70000
+    int l_id = 0;
+#else
     size_t l_id = 0;
+#endif
     // zval* params = NULL;
     
     auto &idWorker = Singleton<IdWorker>::instance();
@@ -284,7 +288,7 @@ PHP_METHOD(SEASSNOWFLAKE_RES_NAME, degenerate)
     idWorker.setWorkerId(Z_LVAL_P(datacenter_id));
 
     #ifndef FAST_ZPP
-        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &id, &l_id, &params) == FAILURE)
+        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &l_id) == FAILURE)
         {
             return;
         }

From bfe79ed7abdfb65a0b1ab9b12723f1b717d63306 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 25 Aug 2021 09:46:34 +0200
Subject: [PATCH 2/2] fix for 5.4 (lvalue required)

---
 SeasSnowflake.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/SeasSnowflake.cpp b/SeasSnowflake.cpp
index 06b3f5f..be2b846 100755
--- a/SeasSnowflake.cpp
+++ b/SeasSnowflake.cpp
@@ -313,7 +313,7 @@ PHP_METHOD(SEASSNOWFLAKE_RES_NAME, degenerate)
         uint dataCenterId=idWorker.degenerateDataCenterId(id_i);
         uint64_t beginTimestamp=idWorker.degenerateBeginTimestamp(id_i);
         uint64_t timestamp= idWorker.degenerateTimestamp(id_i);
-        zval arr;
+        zval arr, *parr = &arr;
 
         array_init(&arr);
         add_assoc_long_ex(&arr, "worker_id", strlen("worker_id"), workerId);
@@ -323,7 +323,7 @@ PHP_METHOD(SEASSNOWFLAKE_RES_NAME, degenerate)
         add_assoc_long_ex(&arr, "begin_timestamp", strlen("begin_timestamp"), beginTimestamp);
         add_assoc_long_ex(&arr, "interval", strlen("interval"), interval);
 
-        RETURN_ZVAL(&arr, 0, 1);
+        RETURN_ZVAL(parr, 0, 1);
      } catch (const std::exception& e){
          #if PHP_VERSION_ID < 80000
           sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);