Skip to content

Commit 0d7b46c

Browse files
committed
fix 21705
1 parent e0e2963 commit 0d7b46c

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

ext/zip/php_zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
27882788

27892789
ZIP_FROM_OBJECT(intern, self);
27902790

2791-
PHP_ZIP_STAT_INDEX(intern, index, 0, sb);
2791+
PHP_ZIP_STAT_INDEX(intern, index, flags, sb);
27922792
}
27932793

27942794
if (sb.size < 1) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
ZipArchive::getFromIndex() honors FL_UNCHANGED for deleted entries
3+
--EXTENSIONS--
4+
zip
5+
--FILE--
6+
<?php
7+
$name = __DIR__ . '/ZipArchive_getFromIndex_unchanged_deleted.zip';
8+
9+
$zip = new ZipArchive;
10+
var_dump($zip->open($name, ZipArchive::CREATE));
11+
var_dump($zip->addFromString('foo.txt', 'foo'));
12+
var_dump($zip->addFromString('bar.txt', 'bar'));
13+
var_dump($zip->close());
14+
15+
$zip = new ZipArchive;
16+
var_dump($zip->open($name));
17+
$index = $zip->locateName('bar.txt');
18+
var_dump($index);
19+
var_dump($zip->deleteName('bar.txt'));
20+
21+
var_dump($zip->getFromName('bar.txt', 0, ZipArchive::FL_UNCHANGED));
22+
var_dump($zip->getFromIndex($index, 0, ZipArchive::FL_UNCHANGED));
23+
24+
var_dump($zip->close());
25+
?>
26+
--CLEAN--
27+
<?php
28+
$name = __DIR__ . '/ZipArchive_getFromIndex_unchanged_deleted.zip';
29+
@unlink($name);
30+
?>
31+
--EXPECT--
32+
bool(true)
33+
bool(true)
34+
bool(true)
35+
bool(true)
36+
bool(true)
37+
int(1)
38+
bool(true)
39+
string(3) "bar"
40+
string(3) "bar"
41+
bool(true)

0 commit comments

Comments
 (0)