Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in
It solved when switched off zlib.output_compression in php.ini
zlib.output_compression = Off
WordPress attempts to flush the output buffers on shutdown. It fails because you have already called ob_end_flush()
.
You should be able to keep compression on, and simply unhook the flush action:
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
You can now call ob_end_flush()
manually, and keep zlib compression on.
I found a particular plug-in was the cause on one of our client's WP sites.
In this case it was caused by the "NextGEN Gallery" plug-in, but weirdly simply deactivating and then activating the plug-in resolved the issue.
For anyone else having this problem it would be worth looking for suspect front end facing plug-ins and trying the same. If you find that the issue comes back when the culprit plug-in is reactivated you should file an issue with the plug-in author.
I wouldn't recommend disabling the wp_ob_end_flush_all()
function entirely, and I definitely wouldn't turn off zlib.output_compression
in your php.ini
file. Here's a better approach that replaces the source code causing the issue, and preserves the underlying functionality:
/**
* 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 the cause, and why this is probably the best approach can be found here: Quick Fix for WordPress ob_end_flush() Error