summaryrefslogtreecommitdiffstats
path: root/xlswriter-php82.patch
blob: 912beda03df8e4681583873c86aae7b91f55deed (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
From 5ec02a705d9171150035b028af622f913088ff7f Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 16 Sep 2022 11:43:18 +0200
Subject: [PATCH] Fix for PACKED array on PHP 8.2

---
 kernel/excel.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/excel.c b/kernel/excel.c
index 698db1f..093c1ce 100644
--- a/kernel/excel.c
+++ b/kernel/excel.c
@@ -627,7 +627,8 @@ PHP_METHOD(vtiful_xls, header)
  */
 PHP_METHOD(vtiful_xls, data)
 {
-    zend_ulong column_index = 0;
+    zend_ulong column_index = 0, index;
+    zend_string *key;
     zval *data = NULL, *data_r_value = NULL;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -651,17 +652,16 @@ PHP_METHOD(vtiful_xls, data)
 
         column_index = 0;
 
-        ZEND_HASH_FOREACH_BUCKET(Z_ARRVAL_P(data_r_value), Bucket *bucket)
+        ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(data_r_value), index, key, data) {
             // numeric index rewriting
-            if (bucket->key == NULL) {
-                column_index = bucket->h;
+            if (key == NULL) {
+                column_index = index;
             }
-
-            type_writer(&bucket->val, SHEET_CURRENT_LINE(obj), column_index, &obj->write_ptr, NULL, obj->format_ptr.format);
+            type_writer(data, SHEET_CURRENT_LINE(obj), column_index, &obj->write_ptr, NULL, obj->format_ptr.format);
 
             // next number index
             ++column_index;
-        ZEND_HASH_FOREACH_END();
+        } ZEND_HASH_FOREACH_END();
 
         SHEET_LINE_ADD(obj)
     ZEND_HASH_FOREACH_END();