Skip to content

Commit bcfcfb2

Browse files
committed
Fix bug #61519 test fails, should pass - ext/zlib/tests/bug60761.phpt
1 parent b638d30 commit bcfcfb2

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

ext/zlib/tests/bug60761.phpt

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
11
--TEST--
2-
checks zlib compression size is always the same no matter how many times its run
2+
checks zlib compression output size is always the same
33
--SKIPIF--
44
<?php if (!extension_loaded("zlib")) print "skip"; ?>
5+
--CGI--
6+
1
57
--FILE--
68
<?php
79

8-
ob_start();
9-
phpinfo();
10-
$html = ob_get_clean();
10+
// the INI directives from bug #60761 report
11+
ini_set('zlib.output_compression', '4096');
12+
ini_set('zlib.output_compression_level', '9');
13+
14+
// try to duplicate the original bug by running this as a CGI
15+
// test using ob_start and zlib.output_compression(or ob_gzhandler)
16+
// so it follows more of the original code-path than just calling
17+
// gzcompress on CLI or CGI
1118

1219
$lens = array();
1320

14-
for ( $i=0 ; $i < 200 ; $i++ ) {
15-
//zlib.output_compression = On
16-
//zlib.output_compression_level = 9
17-
$compressed = gzcompress($html, 9);
18-
19-
$len = strlen($compressed);
21+
for ( $i=0 ; $i < 100 ; $i++ ) {
22+
23+
// can't use ob_gzhandler with zlib.output_compression
24+
ob_start();//"ob_gzhandler");
25+
phpinfo();
26+
$html = ob_get_clean();
27+
28+
$len = strlen($html);
2029

2130
$lens[$len] = $len;
2231
}
2332

2433
$lens = array_values($lens);
2534

26-
echo "Compressed lengths\n";
27-
var_dump($lens);
35+
echo "Compressed Lengths\n";
36+
37+
// pass == only ONE length for all iterations
38+
// (length didn't change during run)
39+
//
40+
// hard to anticipate what 'correct' length should be since
41+
// return value of phpinfo() will vary between installations...
42+
// just check that there is only one length
43+
//
44+
var_dump($lens); // show lengths to help triage in case of failure
45+
46+
// expected headers since its CGI
2847

2948
?>
30-
--EXPECTREGEX--
31-
Compressed lengths
49+
--EXPECTF--
50+
%s
3251
array(1) {
3352
[0]=>
3453
int(%d)

0 commit comments

Comments
 (0)