HomeWordpress FixesHow to fix ob_end_flush(): failed to send buffer of zlib output compression...

How to fix ob_end_flush(): failed to send buffer of zlib output compression error

ob_end_flush(): failed to send buffer of zlib output compression

ob_end_flush This occurs when your WordPress theme or plugins employ output buffering but fail to flush the output properly, or when there is a problem with the buffer’s zlib compression. The built-in wp ob end flush all() function should be removed from the shutdown action hook, according to most recommendations. This function is there for a reason, and you should not disable it solely to avoid a PHP warning. Here’s a better approach to fix your WordPress “failed to submit buffer of zlib output compression” errors.

Fix #1 Inserting custom codes in functions.php

Instead of completely eliminating wp ob end flush all(), replace it with the following code to keep the underlying functionality while also removing the PHP notice from the bottom of your WordPress site.

/**
 * 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() );
} );

Fix #2 Switched off zlib.output_compression in php.ini

Add below codes to php.ini file

zlib.output_compression = Off

RELATED ARTICLES
- Advertisment -

Latest

How to whitelist website on AdBlocker?