I MIGHT have fixed the infamous ob_end_flush error?
-
I have been having this stupid error for practically every WordPress site i have ever run.
I have no idea how to trace why it’s happening since there appears to be no simple way to enable a stack trace in order to see what functions were called to create a page.
Anyway, I was getting the error at line 4341 in my functions.php file.
In this function:
function wp_ob_end_flush_all() {
// print wp_debug_backtrace_summary();
$levels = ob_get_level();
for ( $i = 0; $i < $levels; $i++ ) {
ob_end_flush();
}
}And in some frustration I subtracted 1 from the $levels variable.
function wp_ob_end_flush_all() {
// print wp_debug_backtrace_summary();
$levels = ob_get_level();
for ( $i = 0; $i < $levels-1; $i++ ) {
ob_end_flush();
}
}And the warning went away. This seems MAD if this is ACTUALLY the solution. Because I see a lot of frustrated and puzzled people having this problem.
I decided to dig a little deeper and find the PHP function ob_end_flush()
https://www.php.net/manual/en/function.ob-end-flush.php
On this page there are some user comments (from many years ago to be sure) about zlib compression increasing the level by 1?
I certainly have zlib compression turned on for my sites.
And so do most people who are having this problem. (And no, turning off compression is NOT an acceptable option, despite all the people who suggest it.)
Then I found this little gem under Examples:
<?php
while (@ob_end_flush());
?>So, I decided to try it in the WP function
function wp_ob_end_flush_all() {
while (@ob_end_flush());
}And still, no warnings are being thrown up.
IS this a legitimate fix? IS there anything to say this is a problem to do?
If this seems legitimate, then can someone PLEASE pass this to the WP developers so they can fix the partially broken wp_ob_end_flush_all() function.
Thanks
- The topic ‘I MIGHT have fixed the infamous ob_end_flush error?’ is closed to new replies.