summaryrefslogtreecommitdiffstats
path: root/4.patch
blob: c5b70abe477d4df921f01f7612ac7b5aace37b06 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
From 1225c9240e0e368dad6ccc5f618e000560b4925d Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 26 Jun 2018 15:22:42 +0200
Subject: [PATCH 1/2] relax tests for 7.3 (bool/boolean, main/count)

---
 tests/002.phpt | 2 +-
 tests/003.phpt | 2 +-
 tests/008.phpt | 2 +-
 tests/079.phpt | 4 ++--
 tests/092.phpt | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/002.phpt b/tests/002.phpt
index f90617a..358aba8 100644
--- a/tests/002.phpt
+++ b/tests/002.phpt
@@ -163,6 +163,6 @@ array(2) {
 
 Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
 
-Warning: rar_list() expects parameter 1 to be RarArchive, boolean given in %s on line %d
+Warning: rar_list() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
 NULL
 Done
diff --git a/tests/003.phpt b/tests/003.phpt
index 2f0a6df..9b77d2f 100644
--- a/tests/003.phpt
+++ b/tests/003.phpt
@@ -89,6 +89,6 @@ object(RarEntry)#%d (%d) {
 
 Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
 
-Warning: rar_entry_get() expects parameter 1 to be RarArchive, boolean given in %s on line %d
+Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
 NULL
 Done
diff --git a/tests/008.phpt b/tests/008.phpt
index f79c97a..f864c97 100644
--- a/tests/008.phpt
+++ b/tests/008.phpt
@@ -28,7 +28,7 @@ bool(false)
 
 Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
 
-Warning: rar_entry_get() expects parameter 1 to be RarArchive, boolean given in %s on line %d
+Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
 NULL
 
 Done
diff --git a/tests/079.phpt b/tests/079.phpt
index f243b85..0ee005a 100644
--- a/tests/079.phpt
+++ b/tests/079.phpt
@@ -48,12 +48,12 @@ Count: 13
 
 * Closed file test (1):
 
-Warning: count(): The archive is already closed in %s on line %d
+Warning: %s(): The archive is already closed in %s on line %d
 int(0)
 
 * Closed file test (2):
 
-Warning: count(): The archive is already closed in %s on line %d
+Warning: %s(): The archive is already closed in %s on line %d
 int(0)
 
 * Closed file test (3, exceptions):
diff --git a/tests/092.phpt b/tests/092.phpt
index 39b8331..6ddd6f2 100644
--- a/tests/092.phpt
+++ b/tests/092.phpt
@@ -54,7 +54,7 @@ Warning: rar_allow_broken_set() expects exactly 2 parameters, 1 given in %s on l
 Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d
 bool(false)
 
-Warning: count(): ERAR_EOPEN (file open error) in %s on line %d
+Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d
 int(0)
 
 * broken file; do not allow broken (explicit)
@@ -62,7 +62,7 @@ int(0)
 Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d
 bool(false)
 
-Warning: count(): ERAR_EOPEN (file open error) in %s on line %d
+Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d
 int(0)
 
 * broken file; allow broken

From 5ca8d78562769fe38c0b8d1b2bcb586f18ca6dd5 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 18 Jul 2018 11:02:14 +0200
Subject: [PATCH 2/2] fix for iterator changes in 7.3.0alpha4

---
 rar_error.c |   2 +-
 rararch.c   | 104 ++++++++++++++++++++++++++++++++----------------------------
 2 files changed, 56 insertions(+), 50 deletions(-)

diff --git a/rar_error.c b/rar_error.c
index 447a19d..13a742b 100644
--- a/rar_error.c
+++ b/rar_error.c
@@ -252,7 +252,7 @@ void minit_rarerror(TSRMLS_D) /* {{{ */
 	rarexception_ce_ptr->ce_flags |= ZEND_ACC_FINAL;
 	zend_declare_property_bool(rarexception_ce_ptr, "usingExceptions",
 		sizeof("usingExceptions") -1, 0L /* FALSE */,
-		ZEND_ACC_PRIVATE | ZEND_ACC_STATIC TSRMLS_CC);
+		ZEND_ACC_STATIC TSRMLS_CC);
 }
 /* }}} */
 
diff --git a/rararch.c b/rararch.c
index 1c065df..06ed9ca 100644
--- a/rararch.c
+++ b/rararch.c
@@ -932,55 +932,6 @@ static void rararch_it_move_forward(zend_object_iterator *iter TSRMLS_DC);
 static void rararch_it_rewind(zend_object_iterator *iter TSRMLS_DC);
 /* }}} */
 
-/* {{{ rararch_it_get_iterator */
-static zend_object_iterator *rararch_it_get_iterator(zend_class_entry *ce,
-													 zval *object,
-													 int by_ref TSRMLS_DC)
-{
-	rararch_iterator	*it;
-	rar_file_t			*rar;
-	int					res;
-
-	if (by_ref) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR,
-			"An iterator cannot be used with foreach by reference");
-	}
-
-	it = emalloc(sizeof *it);
-
-#if PHP_MAJOR_VERSION < 7
-	zval_add_ref(&object);
-	it->parent.data = object;
-	it->value = NULL;
-#else
-	zend_iterator_init((zend_object_iterator *) it);
-	ZVAL_COPY(&it->parent.data, object);
-	ZVAL_UNDEF(&it->value);
-#endif
-
-	it->parent.funcs = ce->iterator_funcs.funcs;
-	it->state = NULL;
-
-	res = _rar_get_file_resource_ex(object, &rar, 1 TSRMLS_CC);
-	if (res == FAILURE)
-		php_error_docref(NULL TSRMLS_CC, E_ERROR,
-			"Cannot fetch RarArchive object");
-	if (rar->arch_handle == NULL)
-		php_error_docref(NULL TSRMLS_CC, E_ERROR,
-			"The archive is already closed, cannot give an iterator");
-	res = _rar_list_files(rar TSRMLS_CC);
-	if (_rar_handle_error(res TSRMLS_CC) == FAILURE) {
-		/* if it failed, do not expose the possibly incomplete entry list */
-		it->empty_iterator = 1;
-	}
-	else
-		it->empty_iterator = 0;
-
-	_rar_entry_search_start(rar, RAR_SEARCH_TRAVERSE, &it->state TSRMLS_CC);
-	return (zend_object_iterator*) it;
-}
-/* }}} */
-
 /* {{{ rararch_it_invalidate_current */
 static void rararch_it_invalidate_current(zend_object_iterator *iter TSRMLS_DC)
 {
@@ -1147,6 +1098,59 @@ static zend_object_iterator_funcs rararch_it_funcs = {
 };
 /* }}} */
 
+/* {{{ rararch_it_get_iterator */
+static zend_object_iterator *rararch_it_get_iterator(zend_class_entry *ce,
+													 zval *object,
+													 int by_ref TSRMLS_DC)
+{
+	rararch_iterator	*it;
+	rar_file_t			*rar;
+	int					res;
+
+	if (by_ref) {
+		php_error_docref(NULL TSRMLS_CC, E_ERROR,
+			"An iterator cannot be used with foreach by reference");
+	}
+
+	it = emalloc(sizeof *it);
+
+#if PHP_MAJOR_VERSION < 7
+	zval_add_ref(&object);
+	it->parent.data = object;
+	it->value = NULL;
+#else
+	zend_iterator_init((zend_object_iterator *) it);
+	ZVAL_COPY(&it->parent.data, object);
+	ZVAL_UNDEF(&it->value);
+#endif
+
+#if PHP_VERSION_ID < 70300
+	it->parent.funcs = ce->iterator_funcs.funcs;
+#else
+	it->parent.funcs = &rararch_it_funcs;
+#endif
+	it->state = NULL;
+
+	res = _rar_get_file_resource_ex(object, &rar, 1 TSRMLS_CC);
+	if (res == FAILURE)
+		php_error_docref(NULL TSRMLS_CC, E_ERROR,
+			"Cannot fetch RarArchive object");
+	if (rar->arch_handle == NULL)
+		php_error_docref(NULL TSRMLS_CC, E_ERROR,
+			"The archive is already closed, cannot give an iterator");
+	res = _rar_list_files(rar TSRMLS_CC);
+	if (_rar_handle_error(res TSRMLS_CC) == FAILURE) {
+		/* if it failed, do not expose the possibly incomplete entry list */
+		it->empty_iterator = 1;
+	}
+	else
+		it->empty_iterator = 0;
+
+	_rar_entry_search_start(rar, RAR_SEARCH_TRAVERSE, &it->state TSRMLS_CC);
+	return (zend_object_iterator*) it;
+}
+/* }}} */
+
 void minit_rararch(TSRMLS_D)
 {
 	zend_class_entry ce;
@@ -1170,7 +1174,9 @@ void minit_rararch(TSRMLS_D)
 	rararch_ce_ptr->clone = NULL;
 	rararch_ce_ptr->create_object = &rararch_ce_create_object;
 	rararch_ce_ptr->get_iterator = rararch_it_get_iterator;
+#if PHP_VERSION_ID < 70300
 	rararch_ce_ptr->iterator_funcs.funcs = &rararch_it_funcs;
+#endif
 	zend_class_implements(rararch_ce_ptr TSRMLS_CC, 1, zend_ce_traversable);
 }