Basically even when zlib.output_compression is off PHP triggers a warning when the ob_gzhandler ob_start() callback function is used.
https://bugs.php.net/bug.php?id=55544&edit=1
So I've done a bit of tinkering with 2.3.2 code in case it helps the 2.4 cause, it's a lot of code for a simple operation but that's what nasty bugs give us!
// if gzip_compression is enabled, start to buffer the output
if ( (GZIP_COMPRESSION == 'true') && !headers_sent()
// Need this in the footer
&& ($ext_zlib_loaded = extension_loaded('zlib'))
&& (PHP_VERSION >= '4') ) {
$zlib = ini_get ( 'zlib.output_compression' ); // an empty string where it doesn't exist or is null
$ini_set_available = function_exists('ini_set'); // some hosts disable this
/**
* @see https://bugs.php.net/bug.php?id=55544&edit=1
* PHP 5.4.0 - 5.4.5 - ob_gzhandler always conflicts with zlib.output_compression
*/
$last_known_bugged_version = '5.4.5';
$php_bugged_version = ( (version_compare(PHP_VERSION, '5.4.0') >= 0)
&& (version_compare(PHP_VERSION, $last_known_bugged_version) <= 0 ) ) ? true : false;
// If zlib is null - an empty string - 0 - or off/OFF we take it as being turned off
if ( ( ($zlib == null) || ($zlib == '') ) || $zlib == 0 || strtolower( (string)$zlib ) == 'off' ) {
/**
* No point trying to ini_set if the host has it turned off!
* zlib.output_compression was available from 4.0.5
*/
if ( $ini_set_available && (version_compare(PHP_VERSION, '4.0.5') >= 0 ) ) {
ini_set('zlib.output_compression', 1);
ini_set('zlib.output_compression_level', GZIP_LEVEL);
// If the PHP version is larger than 4.0.4 and it is not a bugged version then we should be ok using the ob_gzhandler callback
} elseif ( (version_compare(PHP_VERSION, '4.0.4') >= 0 ) && !$php_bugged_version ) {
ob_start('ob_gzhandler');
} else { // last ditch defence
include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
ob_start();
ob_implicit_flush();
}
} else ini_set('zlib.output_compression_level', GZIP_LEVEL); // It's on so well set the level
// For use in the footer
$ini_zlib_output_compression = (int)ini_get('zlib.output_compression');
} // end gzip compression
Apologies in advance for when the forum destroys the code spacing.
The $last_known_bugged_version = '5.4.5' would have to be changed if we are really unfortunate and the problem persists in 5.4.6
added a file as the spacing did indeed break.
Edited by FWR Media, 21 July 2012 - 12:29 PM.











