File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -2728,7 +2728,6 @@ PHP_METHOD(ZipArchive, extractTo)
2728
2728
zend_string * files_str = NULL ;
2729
2729
HashTable * files_ht = NULL ;
2730
2730
2731
- zval * zval_file = NULL ;
2732
2731
php_stream_statbuf ssb ;
2733
2732
char * pathto ;
2734
2733
size_t pathto_len ;
@@ -2765,7 +2764,8 @@ PHP_METHOD(ZipArchive, extractTo)
2765
2764
RETURN_FALSE ;
2766
2765
}
2767
2766
for (i = 0 ; i < nelems ; i ++ ) {
2768
- if ((zval_file = zend_hash_index_find (files_ht , i )) != NULL ) {
2767
+ zval * zval_file ;
2768
+ if ((zval_file = zend_hash_index_find_deref (Z_ARRVAL_P (zval_files ), i )) != NULL ) {
2769
2769
switch (Z_TYPE_P (zval_file )) {
2770
2770
case IS_LONG :
2771
2771
break ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #80863 (ZipArchive::extractTo() ignores references)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('zip ' )) die ("skip zip extension not available " );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ $ archive = __DIR__ . "/bug80863.zip " ;
10
+
11
+ $ zip = new ZipArchive ();
12
+ $ zip ->open ($ archive , ZipArchive::CREATE | ZipArchive::OVERWRITE );
13
+ $ zip ->addFromString ("file1.txt " , "contents " );
14
+ $ zip ->addFromString ("file2.txt " , "contents " );
15
+ $ zip ->close ();
16
+
17
+ $ target = __DIR__ . "/bug80683 " ;
18
+ mkdir ($ target );
19
+
20
+ $ files = [
21
+ "file1.txt " ,
22
+ "file2.txt " ,
23
+ ];
24
+ // turn into references
25
+ foreach ($ files as &$ file );
26
+
27
+ $ zip = new ZipArchive ();
28
+ $ zip ->open ($ archive );
29
+ $ zip ->extractTo ($ target , $ files );
30
+ var_dump (is_file ("$ target/file1.txt " ));
31
+ var_dump (is_file ("$ target/file2.txt " ));
32
+ ?>
33
+ --EXPECT--
34
+ bool(true)
35
+ bool(true)
36
+ --CLEAN--
37
+ <?php
38
+ @unlink (__DIR__ . "/bug80863.zip " );
39
+ $ target = __DIR__ . "/bug80683 " ;
40
+ @unlink ("$ target/file1.txt " );
41
+ @unlink ("$ target/file2.txt " );
42
+ @rmdir ($ target );
43
+ ?>
You can’t perform that action at this time.
0 commit comments