ob_gzhandler always conflicts with zlib.output_compression

Bug #55544 ob_gzhandler always conflicts with zlib.output_compression
Submitted: 2011-08-31 02:58 UTC Modified: 2012-07-24 06:55 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: diogin at gmail dot com Assigned: laruence (profile)
Status: Closed Package: Output Control
PHP Version: 5.4.0alpha3 OS: Windows XP SP3 x86
Private report: No CVE-ID: None

 [2011-08-31 02:58 UTC] diogin at gmail dot com

Description:
------------
Windows XP SP3 x86, Apache 2.2, PHP 5.4.0alpha3, with the following php.ini configuration options:

output_buffering = Off
zlib.output_compression = Off

Run this script twice through browser, you will see a warning and a notice:

<?php
ob_start('ob_gzhandler');
echo 'hello, world';
ob_end_flush();
?>

And the error messages are:

Warning: ob_start() [ref.outcontrol]: output handler 'ob_gzhandler' conflicts with 'zlib output compression' in D:\soft\develop\web\php\5.4\0\var\index.php on line 2

Notice: ob_start() [ref.outcontrol]: failed to create buffer in D:\soft\develop\web\php\5.4\0\var\index.php on line 2
hello, world



Test script:
---------------
<?php
ob_start('ob_gzhandler');
echo 'hello, world';
ob_end_flush();
?>

Expected result:
----------------
No warnings or notices will be raised.

Actual result:
--------------
A warning and a notice are raised.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2011-09-19 14:19 UTC] mike@php.net

-Status: Open +Status: Assigned -Assigned To: +Assigned To: mike

 [2011-09-19 14:37 UTC] mike@php.net

-Status: Assigned +Status: Closed

 [2012-04-13 10:25 UTC] jacky at prahec dot com

I have the same problem, using "php_value output_handler ob_gzhandler" in .htaccess produces the same warning all the time. I've been trying to bypass the problem but nothing works.

In 5.3.8 I didn't have that problem. So downgraded for now.

PHP Ini:
output_buffering = Off
zlib.output_compression = Off

 [2012-06-11 22:36 UTC] php at pointpro dot nl

This issue remains on ArchLinux running: PHP 5.4.3 (built: May 31 2012 10:40:02).

Even though zlib.output_compression is set to Off in php.ini and phpinfo(); reports this setting as being off, I still get this warning message at each run of any PHP script. Or more specific:

PHP Warning:  Unknown: output handler 'zlib output compression' conflicts with 'ob_gzhandler' in Unknown on line 0

The same issue happens both when running through lighttpd as when using the CLI. If any more information is required, please let me know which.

 [2012-06-22 13:35 UTC] ewal at pointpro dot nl

You are right. It seems to be fixed in php-5.4.4-1; no more errors now. Thanks.

 [2012-07-02 07:26 UTC] dietmar at gps-tour dot info

Hi, it's not fixed in my PHP Version: 5.4.4-2~dotdeb.0

The Line "ZLIBG(output_compression) = 0;" in ext/zlib/zlib.c from the obove commit 
is not in the actual head or 5.4.4 branch anymore.

 [2012-07-17 14:15 UTC] bugs dot php at mohiva dot com

Same problem here. This bug isn't fixed in 5.4.5RC1.

 [2012-07-20 08:55 UTC] webmaster at abyssunderground dot co dot uk

Still present in the recent 5.4.5 update. Very frustrating.

 [2012-07-20 17:08 UTC] rasmus@php.net

-Status: Closed +Status: Re-Opened

 [2012-07-20 17:08 UTC] rasmus@php.net

Yes, something isn't being reset after the request when you use 
ob_start('ob_gzhandler')

 [2012-07-20 17:23 UTC] laruence@php.net

-Assigned To: mike +Assigned To: laruence

 [2012-07-23 14:23 UTC] bugs dot php at mohiva dot com

The error message is gone, but the gzip compression doesn't work no longer.

The configuration that I use in php-fpm.conf is:
php_flag[output_buffering] = on
php_flag[zlib.output_compression] = off
php_value[output_handler] = ob_gzhandler

Can someone of the devs mark the bug 62335 as duplicate.

 [2012-07-24 02:44 UTC] laruence@php.net

I tested with php build server, didn't reproduce your issue.
test script: 
<?php
ob_start('ob_gzhandler');
echo 'hello, world';
ob_end_flush();
?>

server response:
HTTP/1.1 200 OK

Host: inf-dev-porsche.weibo.com:8964

Connection: close

X-Powered-By: PHP/5.5.0-dev

Content-Encoding: gzip

Vary: Accept-Encoding

Content-type: text/html

 [2012-07-24 03:33 UTC] laruence@php.net

oh, I mis-understand your codes,  verified.

 [2012-07-24 05:12 UTC] laruence@php.net

Here is the problem
ext/zlib/zlib.c
@@ -205,7 +205,7 @@ static int php_zlib_output_handler(void **handler_context, 
php_output_context *o
 		if (SUCCESS == 
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags TSRMLS_CC)) {
 			/* only run this once */
 			if (!(flags & PHP_OUTPUT_HANDLER_STARTED)) {
				if (SG(headers_sent) || 
!ZLIBG(output_compression)) {  

seems we need a bigger work to resolve this

 [2012-07-24 06:17 UTC] laruence@php.net

here is the confusion(assuming -d output_handler=ob_gzhandler -d 
zlib.output_compression=0) :

1. php.output_handler will change the ZLIGB(output_compression) before the zlib 
RINIT 
2. in zlib RINIT, we set the ZLIBG(output_compression) to default value(ini)

3. if we don't override the ZLIBG(output_compression), then in the 
php_zlib_output_compression_start which will be called in RINT will try to start 
zlib compression handler (although it depends on the requeset header), then, the 
conflict warning will be threw.

4. if we override it, then it the php_zlib_output_compression_start, it will 
return FALIURE, and no compression occurred(see the codes from my previous 
reply)

so, the key problem is multi-featrues depends on one global flag -> 
ZLIBG(output_compression).

 [2012-07-24 12:22 UTC] bugs dot php at mohiva dot com

Now, it works for me.

 [2012-07-29 11:36 UTC] knorge at gmx dot de

I want to test the mentioned snapshot but none of the links are working on this page: http://windows.php.net/snapshots/
Where have they gone? I am using Win7 x64 and this bug is driving me crazy for some time. Will it be finally fixed in PHP 5.4.6?

 [2013-04-21 10:12 UTC] sweet_philippe at hotmail dot com

Problems occurs for me on :

php-5.4.13-1.fc18.x86_64 + httpd-2.4.4-2.fc18.x86_64
and
php-5.4.11-1.fc18.x86_64 + httpd-2.4.3-15.fc18.x86_64

zlib.output_compression = Off in php.ini
With apache mod_deflate on or off it is the same.

Any advise to fix it please ?

 [2016-03-29 00:29 UTC] welfordmartin at gmail dot com

Seem to be getting this bug again in 5.5.10 (cPanel)

 [2016-05-31 17:16 UTC] harrie_xo at yahoo dot co dot id

I'm encounter this bug again in php 7. Can anyone help?

 [2020-09-21 19:56 UTC] stefan dot coetzee at gmail dot com

Having the same issue - using php v7.0.10.  It is now 2020 - first reported in 2011 already...?