1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed ob_gzhandler Workaround Disables Gzip Compression

Discussion in 'Resolved Bug Reports' started by thedude, Jan 8, 2014.

  1. thedude

    thedude Well-Known Member

    PHP 5.5.7 running on Apache 2.4.7
    XenForo 1.2.4

    zlib.output_compression = On
    zlib.output_compression_level = 1
    zlib.output_handler not set

    I noticed the pages being served by xenforo on my server weren't compressed, so I created a simple test script, ran it off my server and it came back correctly with gzip compression.

    after digging into the code, it turns out this chunk of code is preventing my server from compressing pages:

    			// see http://bugs.php.net/bug.php?id=36514
    			// and http://xenforo.com/community/threads/53637/
    			if (!@ini_get('output_handler'))
    				$level = ob_get_level();
    				while ($level)
    					$newLevel = ob_get_level();
    					if ($newLevel >= $level)
    					$level = $newLevel;
    Commenting it out gives me proper compression again
    ANGEL OF FIRE and Mouth like this.
  2. Mike

    Mike XenForo Developer Staff Member

    In my testing, I don't actually get compression even with those lines commented out. Looking at the PHP source itself, simply sending a content length header disables zlib.output_compression internally (and we do send a content length by default).

    However, I have changed this for 1.3 - zlib compression is effectively disabled for the internal handling. I have only changed this for 1.3 as I want it to go through a beta period to make sure it doesn't cause problems in certain specific configurations.
    thedude likes this.

Share This Page