|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51650 gzinflate return values don't match docs
Submitted: 2010-04-23 17:21 UTC Modified: 2010-05-10 10:52 UTC
From: marcus at synchromedia dot co dot uk Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.14, 5.3.x OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: marcus at synchromedia dot co dot uk
New email:
PHP Version: OS:


 [2010-04-23 17:21 UTC] marcus at synchromedia dot co dot uk
gzinflate is supposed to return false if it tries to inflate something that's not 
valid deflated data. It does this on PHP 5.2, but returns an empty string in 5.3.
This is either a docs problem or a BC break between 5.2 and 5.3. I can't find 
anything in bugs, docs, release notes or the 5.2 to 5.3 upgrade guide about this.

Test script:
$a = gzdeflate('abc');
$b = gzinflate($a);
$c = gzinflate('abc');

Expected result:
(I get this under PHP 5.2.4 on linux)
string(3) "abc"
PHP Warning:  gzinflate(): buffer error in test.php on line 5

Actual result:
(I get this from PHP 5.3.2 built from MacPorts on OS X)
string(3) "abc"
string(0) ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-23 18:32 UTC]
-PHP Version: 5.3.2 +PHP Version: 5.2.14, 5.3.x
 [2010-04-23 18:32 UTC]
I can reproduce it on PHP 5.2.14-dev.
 [2010-04-24 18:38 UTC]
-Package: Zlib Related +Package: Documentation problem
 [2010-05-09 22:29 UTC]
-Status: Open +Status: Bogus
 [2010-05-09 22:29 UTC]
The documentation does not say that gzinflate will return false if the data passed 
has not been deflated.
 [2010-05-10 10:52 UTC] marcus at synchromedia dot co dot uk
It's true that it doesn't explicitly say that, but it is still the case that 5.2 returns an 
error but 5.3 does not. Exactly why there is a difference isn't really that important - that 
there _is_ a difference is a BC break, and that's definitely not bogus. It's also been 
independently verified courtesy of felipe.
As I said when I reported this: "This is either a docs problem or a BC break" - when 
documentation doesn't match behaviour, either the behaviour or the documentation is wrong - 
you can't have it both ways. Since you're saying the docs are right, the behaviour must be 
If it doesn't complain about invalid input data, what use is the return value? I guess there 
might be a few other circumstances such as running out of memory or missing the input value, 
but both of those would be caught and reported by other PHP mechanisms. If the parameter was 
missing atogether it would produce a compile-time error (i.e. nothing to do with a return 
value), but losing the ability to spot errors at runtime is a serious loss - it certainly 
caused problems for my app, which is why I reported this in the first place.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 07:03:36 2021 UTC