admin管理员组

文章数量:1291026

At the bottom of my WP-admin pages I get this:

ob_end_flush(): failed to send buffer of zlib output compression (1) in C:\Users\anticaking\Desktop\Website\wordpress\wp-includes\functions.php on line 3718.

Line 3718:

function wp_ob_end_flush_all() {
    $levels = ob_get_level();
    for ($i=0; $i<$levels; $i++)
        ob_end_flush();
}

I've removed all plug-ins and swapped themes and still get the error so I cannot pinpoint what is causing it. What is it and how do I fix this?

At the bottom of my WP-admin pages I get this:

ob_end_flush(): failed to send buffer of zlib output compression (1) in C:\Users\anticaking\Desktop\Website\wordpress\wp-includes\functions.php on line 3718.

Line 3718:

function wp_ob_end_flush_all() {
    $levels = ob_get_level();
    for ($i=0; $i<$levels; $i++)
        ob_end_flush();
}

I've removed all plug-ins and swapped themes and still get the error so I cannot pinpoint what is causing it. What is it and how do I fix this?

Share Improve this question edited Feb 12, 2017 at 19:15 lurning too koad asked Feb 12, 2017 at 5:26 lurning too koadlurning too koad 6292 gold badges7 silver badges13 bronze badges 3
  • Possible duplicate of ob_end_flush error when using wpdb in plugin – prosti Commented Feb 12, 2017 at 10:29
  • What is your PHP version? – prosti Commented Feb 12, 2017 at 10:29
  • @prosti version 7.0.9 – lurning too koad Commented Feb 12, 2017 at 16:53
Add a comment  | 

4 Answers 4

Reset to default 3

I also had this issue with wordpress and couldn't properly resolve it. Ended up with this filthy hack to prevent the error from showing:

// Get the current error reporting level
$e_level = error_reporting();

// Turn off error reporting
error_reporting(0);

ob_start();
echo 'This is a horrible hack';
$buffer_contents = ob_get_clean();
ob_end_flush();

// Reset error reporting level to previous
error_reporting($e_level);

Everything does seem to work as expected, however I'm not proud of it!

bool ob_end_flush ( void ) This function will send the contents of the topmost output buffer (if any) and turn this output buffer off. If you want to further process the buffer's contents you have to call ob_get_contents() before ob_end_flush() as the buffer contents are discarded after ob_end_flush() is called.

for more: http://php/manual/en/function.ob-end-flush.php

Try this, put this into, functions.php file. remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );

I wouldn't recommend disabling the wp_ob_end_flush_all() function entirely, there's a good reason it's there. Instead, try replacing it with the following:

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

I have a write-up with more details on what's going on, and why this is the best approach to fix it: Quick Fix for WordPress ob_end_flush() Error

I tried a brute-force approach which worked (I'm not satisfied with it, but hope this can help someone):

In the last line of the functions.php in the /wp-content/themes/<theme_directory>, add the following line:

ob_get_clean();

本文标签: How to fix obendflush() error