Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable zlib.output_compression on WordPress : Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /path/wp-includes/functions.php on line 3282 via https://core.trac.wordpress.org/ticket/18525
SOLUTIONS I have came across so far:
======================== SOLUTION 1 ====================
In plugins (or somewhere) you probably have this code:
ini_set('zlib.output_compression', '1');
so, I replaced that code with
if (!is_admin()) ob_start('ob_gzhandler'); //because, in admin pages, it causes plugin installation freezing
and Compression will be remained still ON.
======================== SOLUTION 2 ====================
You may have to use:
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
======================== SOLUTION 3 via @Kevinlearynet ====================
/**
* Proper ob_end_flush() for all levels
*
* This replaces the WordPress `wp_ob_end_flush_all()` function
* with a replacement that doesn't cause PHP notices.
*/
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
while ( @ob_end_flush() );
} );
@Kevinlearynet

This comment has been minimized.

Copy link

Kevinlearynet commented Dec 11, 2019

Solution 3

/**
 * Proper ob_end_flush() for all levels
 *
 * This replaces the WordPress `wp_ob_end_flush_all()` function
 * with a replacement that doesn't cause PHP notices.
 */
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
   while ( @ob_end_flush() );
} );

More details on why this is the best option can be found here:

I hope this helps!

@loorlab

This comment has been minimized.

Copy link
Owner Author

loorlab commented Dec 12, 2019

@Kevinlearynet Great !

Thanks !

@mdmoniruzzaman83

This comment has been minimized.

Copy link

mdmoniruzzaman83 commented Feb 28, 2020

Yes, it is worked very fine. Thank you for your solution.

@loorlab

This comment has been minimized.

Copy link
Owner Author

loorlab commented Feb 28, 2020

@mdmoniruzzaman83 yeah !

Yes, it is worked very fine. Thank you for your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.