php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47178 Missing gzip headers in gzencode() output
Submitted: 2009-01-21 10:27 UTC Modified: 2012-11-12 02:33 UTC
From: wharmby at uk dot ibm dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4 OS: Windows XP
Private report: No CVE-ID: None
 [2009-01-21 10:27 UTC] wharmby at uk dot ibm dot com
Description:
------------
Missing gzip headers in output from gzencode() when FORCE_DEFLATE option specified.

Problem persists for all values for $level argument.

Problem seen at PHP 6 level only.

I will be dropping some new PHPT shortly; the PHP 6 version will be tagged with XFAIL section because of this defect.


Reproduce code:
---------------
<?php
var_dump(bin2hex(gzencode(b"Hello World", -1, FORCE_GZIP)));
var_dump(bin2hex(gzencode(b"Hello World", -1, FORCE_DEFLATE)));
?>

Expected result:
----------------
Based on output for same script from 5.2/5.3 I expect something like:

unicode(62) "1f8b0800000000000003f348cdc9c95708cf2fca49010056b1174a0b000000"
unicode(58) "1f8b0800000000000003789cf348cdc9c95708cf2fca490100180b041d"


Actual result:
--------------
unicode(62) "1f8b080000000000000bf348cdc9c95708cf2fca49010056b1174a0b000000"
unicode(38) "789cf348cdc9c95708cf2fca490100180b041d"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-21 11:41 UTC] wharmby at uk dot ibm dot com
New tests dropped for gzencode dropped to php 5.2, 5.3 and 6.

ext/zlib/tests/gzencode_variation2
ext/zlib/tests/gzencode_variation2-win32

in PHP 6 both tagged with XFAIL sections referencing this defect
 [2009-02-28 14:01 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Of course raw deflate encoded data does not have a gzip header.
 [2009-03-02 10:50 UTC] wharmby at uk dot ibm dot com
Hi Mike
      Can you expand on your reason for closing this defect as bogus a little more please given that:

(1) The same test produces different results on php 5.2 and 5.3, 
i.e the output from gzencode() with FORCE_DEFLATE includes the zlib 
headers in both cases. 

(2) The PHP manual says for the gzencode() option 'encoding mode'
	"If you use FORCE_DEFLATE, you get a standard zlib deflated 
        string (inclusive zlib headers) after the gzip file header 
        but without the trailing crc32 checksum. "
This suggests that the output should include zlib headers. 

So if  the PHP 6 behaviour is correct does this not mean there is a 
bug in both PHP 5 code and description of the command in the PHP 
manual ? I raised the bug against PHP 6 as its behaviour differed to 
previous releases and I assumed it was a bug in the new zlib code 
but if the bug lies in PHP % I am happy to fix up the new PHPT's and open a defect against PHP 5. 

Regards
	 Andy 

Andy Wharmby
E-mail: andy_wharmby@uk.ibm.com
 [2009-03-02 11:01 UTC] wharmby@php.net
Hi Mike
  If you think the bug lies in php5 can you re-assign to that release please. I will fix the PHPT accordingly

Regards
   Andy 
 [2009-03-03 22:11 UTC] mike@php.net
Hi Andy!

Sorry for the standard-bla of the quick fix in my previos response.

Interestingly, gzencode(..., FORCE_DEFLATE) does not make any sense to me in PHP versions lower than v6.  I cannot remember why or even if I noticed this legacy behaviour back when I reimplemented zlib code.

For clarification:

RFC1951 = raw deflate
- not much to say here
RFC1950 = zlib encoding, AKA HTTP deflate;
- being [zlib header][deflated data][adler checksum]
RFC1952 = gzip encoding
- being [gzip header][deflated data][crc32 checksum, original size]

The output of PHP5s gzencode(..., FORCE_DEFLATE) is neither of the previous formats, but rather zlib encoded data additionally prepended with a gzip header:
[gzip header][zlib header][deflated data][adler checksum]
This is obscure IMHO.

Obviously, this exists and is even documented for ages, so I kindly ask you to take this issue to internals@ for discussion, so people can decide what's going to happen.

Thank you.
 [2010-05-31 15:23 UTC] mike@php.net
-Status: Suspended +Status: Feedback
 [2010-05-31 15:23 UTC] mike@php.net
So? This code went into trunk now.
 [2011-09-30 06:51 UTC] mike@php.net
-PHP Version: 6CVS-2009-01-21 (snap) +PHP Version: 5.4
 [2011-09-30 06:51 UTC] mike@php.net
So can this ticket be changed to closed? The code will be released with PHP-
5.4...
 [2012-01-18 17:13 UTC] mike@php.net
-Status: Feedback +Status: To be documented
 [2012-01-18 17:13 UTC] mike@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I removed the XFAIL now, and added a note to the UPDGRADE guide.
 [2012-05-15 07:51 UTC] mike@php.net
-Type: Bug +Type: Documentation Problem -Assigned To: mike +Assigned To:
 [2012-11-12 02:33 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328313
Log: Update gzencode() documentation for the new FORCE_DEFLATE behaviour in PHP 5.4.

Fixes doc bug #47178 (Missing gzip headers in gzencode() output).
 [2012-11-12 02:33 UTC] aharvey@php.net
-Status: Open +Status: Closed -Package: Zlib related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2012-11-12 02:33 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC