php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17603 ini_set can't disable zlib
Submitted: 2002-06-04 20:33 UTC Modified: 2004-05-31 19:14 UTC
From: anon-php at sitefoundry dot com Assigned:
Status: Closed Package: Zlib related
PHP Version: 4.3.2 OS: all
Private report: No CVE-ID: None
 [2002-06-04 20:33 UTC] anon-php at sitefoundry dot com
I have the following line in my php.ini:
  zlib.output_compression = On

In experimenting with this, I attempted to disable it within a script (mostly because I wanted to defeat the output buffering that zlib performs). I tried several variations of this line in a script:
    ini_set('zlib.output_compression', '0');
    ini_set('zlib.output_compression', 0);
    ini_set('zlib.output_compression', 'off');

In all cases, output is still compressed. Here is a complete script:
<?
    ini_set('zlib.output_compression', '0');
    echo "If compression is disabled, you should be able to read this via 'lynx -mime_header'";
?>

You can see it here:
http://sitefoundry.com/php/zlib.html

I get this output:
HTTP/1.1 200 OK
Date: Wed, 05 Jun 2002 00:30:51 GMT
Server: Apache/1.3.22
Content-Encoding: gzip
Connection: close
Content-Type: text/html

[non-ascii junk here]

Here is my configure line:
./configure --with-apache=/usr/local/src/apache_1.3.22 --with-gd=/usr/local --with-imap --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/apache/conf --enable-debug=no --enable-track-vars=yes --with-zlib --enable-calendar


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-05 06:21 UTC] sander@php.net
This is quite logical because the output compression starts before your script is executed. If you disable it in your script after it has been started it won't be stopped.

You can _try_ a couple of ob_end_clean()'s (use ob_get_level() to find out how many) to stop it. 

Reopening as a documentation problem.
 [2002-06-05 10:07 UTC] anon-php at sitefoundry dot com
Thanks for the suggestion. I regret to report that I can't make it work: no number of calls to flush(), ob_end_clean(), or ob_implicit_flush() allow the script to output non-compressed data.

So, this comment: "If you disable it in your script after it has been
started it won't be stopped." actually seems to mean "It is not possible to disable zlib output compression or buffering within a script." IMO this would be useful to note on the manual page for ini_set().
 [2002-06-18 06:17 UTC] cortesi@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

changed value from "PHP_INI_ALL" to "PHP_INI_SYSTEM|PHP_INI_PERDIR" for "zlib.output_compression"
 [2003-03-22 14:21 UTC] phpuser at dpiworld dot com
The current online documentation still (incorrectly) lists:  
  zlib.output_compression as "PHP_INI_ALL" 

on page: 
  http://www.php.net/manual/en/ref.zlib.php
 [2003-03-22 14:59 UTC] philip@php.net
The ini table is now autogenerated off PHP source so any changed text in the docs has been written over.  Snipped from the source (/ext/zlib/zlib.c):

STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL..
STD_PHP_INI_ENTRY("zlib.output_compression_level","-1", PHP_INI_ALL..
STD_PHP_INI_ENTRY("zlib.output_handler", "", PHP_INI_ALL..

Either the source needs to be changed OR someone explains how this should be documented.  Reopening as a zlib related problem.
 [2003-03-22 18:48 UTC] sniper@php.net
Docs and sources are fine now.

 [2004-05-31 19:14 UTC] alindeman@php.net
I also removed a comment about being about to ini_set the directive from ref.zlib.php
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of georg
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=69f5cec0fc12bc3506bd4673333c86cb7977924c
Log: fixed bug #17603 - removed zlib features from docu
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of cortesi
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=308800958ed435acc89c96f4f6f35e4eb14c2da3
Log: fix bug #17603
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 21 03:01:24 2020 UTC