Skip to content

Commit 92153dc

Browse files
committed
Added test for bug #51353. It'll be skipped by default and must be
activated manually.
1 parent 0cdc1f5 commit 92153dc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

ext/zip/tests/bug51353.phpt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--TEST--
2+
Bug #51353 ZIP64 problem, archive with 100000 items
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('zip')) die('skip');
6+
die('skip the test might get very long, activate it manually');
7+
--FILE--
8+
<?php
9+
/* This test might get very long depending on the mashine it's running on. Therefore
10+
adding an explicit skip, remove it to run this test. */
11+
set_time_limit(0);
12+
13+
$base_path = dirname(__FILE__);
14+
15+
/* Either we ship a file with 100000 entries which would be >12M big,
16+
or create it dynamically. */
17+
$zip = new ZipArchive;
18+
$r = $zip->open("$base_path/51353.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
19+
if ($r) {
20+
for ($i = 0; $i < 100000; $i++) {
21+
$zip->addFromString("$i.txt", '1');
22+
}
23+
$zip->close();
24+
} else {
25+
die("failed");
26+
}
27+
28+
$zip = new ZipArchive;
29+
$r = $zip->open("$base_path/51353.zip");
30+
if ($r) {
31+
$zip->extractTo("$base_path/51353_unpack");
32+
$zip->close();
33+
34+
$a = glob("$base_path/51353_unpack/*.txt");
35+
echo count($a) . "\n";
36+
} else {
37+
die("failed");
38+
}
39+
40+
echo "OK";
41+
--CLEAN--
42+
<?php
43+
$base_path = dirname(__FILE__);
44+
45+
unlink("$base_path/51353.zip");
46+
47+
$a = glob("$base_path/51353_unpack/*.txt");
48+
foreach($a as $f) {
49+
unlink($f);
50+
}
51+
rmdir("$base_path/51353_unpack");
52+
--EXPECT--
53+
100000
54+
OK

0 commit comments

Comments
 (0)