Last active
March 30, 2021 12:35
-
-
Save loorlab/028d9fca02e6e4f85d1a to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Great !
Thanks !
Yes, it is worked very fine. Thank you for your solution.
@mdmoniruzzaman83 yeah !
Yes, it is worked very fine. Thank you for your solution.
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!
Hi @Kevinlearynet,
Thanks for the solution. I was just curious, does this solution actually solve the issue or is it something that just hides the error. If it just hides the error or is a quick fix, what do we need to do to solve this issue from the root. :)
Thanks again,
-Swadhin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution 3
More details on why this is the best option can be found here:
I hope this helps!