Fix for WordPress ob_end_flush() Error


If you get "ob_end_flush()" Error in the footer of your website, a quick way to fix that

example:

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

    
To fix this, you can try putting this code in your "functions.php" file


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


You can also try placing this code into the "php.ini"

zlib.output_compression = Off

In the end, if that doesn't work you can just set wp-debug to OFF which turns off all PHP Errors (this can be found in your "config.php" file
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );​



Did you find this article useful?



  • Monthly Maintenance Website Checklist

    Here's a list of items that you should check every month to see if a client's site is up-to-date: WordPress Plugins PHP version Before you start upd...

  • Google Analytics setup for Shopify

    Google Analytics Setup on WordPress(1) Log in to mybusiness@702pros.com email    (a) Open PulseNest.  Search for 702Pros.  Select ...

  • How to Setup Webmail on An Apple Device

    Here's how to set up a webmail account on an Apple device like an iPhone or iPad: Go to Settings > Mail, then tap Accounts. Tap Add Account, tap ...

  • Swap Usage - WHM

    Swap, is a secondary (disk-based) storage for your RAM:  The main purpose of this secondary storage is to avoid server crashes having to do with ...

  • duplicate cpanel

    To duplicate a Cpanel, you can use a simple method is your server has this feature. PLEASE CHECK THAT THERE IS BACKUPS FOR THE CPANEL ACCOUNT BEFORE P...