|
1 | 1 | --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 |
3 | 3 | --SKIPIF--
|
4 | 4 | <?php if (!extension_loaded("zlib")) print "skip"; ?>
|
| 5 | +--CGI-- |
| 6 | +1 |
5 | 7 | --FILE--
|
6 | 8 | <?php
|
7 | 9 |
|
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 |
11 | 18 |
|
12 | 19 | $lens = array();
|
13 | 20 |
|
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); |
20 | 29 |
|
21 | 30 | $lens[$len] = $len;
|
22 | 31 | }
|
23 | 32 |
|
24 | 33 | $lens = array_values($lens);
|
25 | 34 |
|
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 |
28 | 47 |
|
29 | 48 | ?>
|
30 |
| ---EXPECTREGEX-- |
31 |
| -Compressed lengths |
| 49 | +--EXPECTF-- |
| 50 | +%s |
32 | 51 | array(1) {
|
33 | 52 | [0]=>
|
34 | 53 | int(%d)
|
|
0 commit comments